Skip to content

Instantly share code, notes, and snippets.

@hirejordansmith
Last active April 27, 2020 12:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirejordansmith/bd54896f06b31b5a6533705c383e9d2a to your computer and use it in GitHub Desktop.
Save hirejordansmith/bd54896f06b31b5a6533705c383e9d2a to your computer and use it in GitHub Desktop.
How to automatically reload a Gravity Form in a modal
// This would be added to a callback or event function
// Replace "82" with the ID of your form
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
// Fancybox example using a link to trigger the modal
// Replace ".open-popup" with your modal trigger
// Replace "82" with the ID of your form
$('.open-popup').fancybox({
afterClose: function() {
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
}
});
// Example of how to bind to an already initialized Fancybox Popup
// Replace "82" with the ID of your form
$( document ).on( 'afterClose', function() {
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
});
// Magnific Popup example using a link to trigger the modal
// Replace ".open-popup" with your modal trigger
// Replace "82" with the ID of your form
$('.open-popup').magnificPopup({
type:'inline',
callbacks: {
close: function() {
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
}
}
});
// Example of how to bind to an already initialized Magnific Popup
// Replace ".open-popup" with your modal trigger
// Replace "82" with the ID of your form
$('.open-popup').on('mfpClose', function() {
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
});
// Popup Maker example using a link to trigger the modal
// Replace "13256" with the ID of your modal
// Replace "82" with the ID of your form
$('#pum-13256').on('pumAfterClose', function() {
var gwrf = window.gwrf_82;
if( typeof gwrf != 'undefined' ) {
gwrf.reloadForm();
}
});
@avinx-niels
Copy link

Hello Jordan,

I have a question, maybe you can help me. We have a modalbox in the footer of our website www.dcmnt.nl/home. When you click on 'Inschrijven nieuwsbrief' (translated 'Subscribe newsletter) it triggers the popup. In the popup you can subscribe with Gravity Forms. When you click on 'Inschrijven' (translated 'Subscribe') the page reloads and the popup is gone. Is there a way to re-open the popup after 'Subscribe', so you can see the 'Thank you page'. Hope you can help me.

Kind regards, Niels klein Avink (The Netherlands)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment