|
1 | | -// Magnific Popup example using a link to trigger the modal |
2 | | -// Replace ".open-popup" with your modal trigger |
3 | | -// Replace "82" with the ID of your form |
4 | | -$('.open-popup').magnificPopup({ |
5 | | - type:'inline', |
6 | | - callbacks: { |
7 | | - close: function() { |
8 | | - var gwrf = window.gwrf_82; |
9 | | - if( typeof gwrf != 'undefined' ) { |
10 | | - gwrf.reloadForm(); |
11 | | - } |
12 | | - } |
13 | | - } |
14 | | -}); |
| 1 | +/** |
| 2 | + * Gravity Perks // Reload Form // Reload Form in Magnific Modal |
| 3 | + * https://gravitywiz.com/automatically-reload-gravity-form-modal-closed/ |
| 4 | + * |
| 5 | + * Describe this snippet's purpose and usage. Be generous when describing both. There |
| 6 | + * is no maximum description length. |
| 7 | + * |
| 8 | + * Instructions: |
| 9 | + * |
| 10 | + * 1. Install this snippet with our free Custom JavaScript plugin. |
| 11 | + * https://gravitywiz.com/gravity-forms-custom-javascript/ |
| 12 | + * 2. Two examples are included below. Remove the example that does not match your use case. |
| 13 | + */ |
| 14 | +// Example #1 – Initialize a new Magnific Popup that will automatically reload the form when the modal is closed. |
| 15 | +// Update ".open-popup" to the selector for the element that will open the modal. |
| 16 | +$( '.open-popup' ).magnificPopup( { |
| 17 | + type:'inline', |
| 18 | + callbacks: { |
| 19 | + close: function() { |
| 20 | + // Update "82" to the ID of the form within the modal. |
| 21 | + var gwrf = window.gwrf_82; |
| 22 | + if( typeof gwrf != 'undefined' ) { |
| 23 | + gwrf.reloadForm(); |
| 24 | + } |
| 25 | + } |
| 26 | + } |
| 27 | +} ); |
15 | 28 |
|
16 | | -// Example of how to bind to an already initialized Magnific Popup |
17 | | -// Replace ".open-popup" with your modal trigger |
18 | | -// Replace "82" with the ID of your form |
19 | | -$('.open-popup').on('mfpClose', function() { |
20 | | - var gwrf = window.gwrf_82; |
21 | | - if( typeof gwrf != 'undefined' ) { |
22 | | - gwrf.reloadForm(); |
23 | | - } |
24 | | -}); |
| 29 | +// Example #2 – Automatically reload a form when a previously configured Magnific popup is closed. |
| 30 | +// Update ".open-popup" to the selector for the element that has been previoulsy been initialized with Magnific. |
| 31 | +$( '.open-popup' ).on( 'mfpClose', function() { |
| 32 | + // Update "82" to the ID of the form within the modal. |
| 33 | + var gwrf = window.gwrf_82; |
| 34 | + if ( typeof gwrf != 'undefined' ) { |
| 35 | + gwrf.reloadForm(); |
| 36 | + } |
| 37 | +} ); |
0 commit comments