I have a form that opens in a lightbox upon button press. Once the form is filled out it redirects to a pdf for download. The problem is it stays within the lightbox frame. Is there a way to exit the lightbox and show the pdf after form submission? Thanks!
Hey cnpetr,
Thank you for the inquiry.
There’s no built-in option for this by default, but you can try creating custom script to close the lightbox on form submission or when the submit button is clicked. For example:
jQuery(document).on('av_resize_finished', function() {
setTimeout(function() {
if (jQuery('.ajaxresponse:visible').length) {
// close popup here
// open a new tab with the pdf
}
}, 300);
});
OR
jQuery(document).ready(function($) {
$('.avia_ajax_form input[type="submit"]').on('click', function(e) {
// close popup here
// open a new tab with the pdf
});
});
Another alternative is to place the download form on its own page instead of using a lightbox.
Best regards,
Ismael
what kind of form is it? If you are using contact form 7 you can listen to wpcf7mailsent and after a time you can close the popup with it.
maybe your form got something similar.
for example you can close a magnificPopup by adding this to your popup function:
document.addEventListener( 'wpcf7mailsent', function( event ) {
setTimeout(function() {
$.magnificPopup.close();
}, 1000);
}, false );
Thank you both! I’ve gone ahead and made it a page instead of using the lightbox for now.