POP UP with Contact form 7 issue


I'm using the Pop up plugin with a contact form 7 form. When users click the "submit" button, the pop-up would close and page would refresh, and then after a while the same pop up would appear with the "thank you for submitting your form" message.

Is there a way to keep the pop-up window open when a user submits the form or has an error when filling out the form?

I noticed this is a known issue and tried the solution from a support forum to use the following script in the footer. It worked on Chrome but not on Safari... Please advise...

I also followed the instruction to grand support access.

Thank you!

jQuery(document).on( 'popup-submit-done', function(event, popup, data){
// Option A: Do not ever close Popup 18 automatically!
if ( data.popup_id == 18 ) {
data.close_popup = false;

// Option B: Do not close Popup if there is an Ajax JSON response that contains "mailSent: false"
if ( undefined !== data.last_ajax.responseJSON ) {
response = data.last_ajax.responseJSON;
if ( false === response.mailSent ) {
data.close_popup = false;