| @@ -1,27 +1,27 @@ | ||
| 1 | -let iframeCounter = 1; | |
| 2 | -const $ = window.jQuery || jQuery; | |
| 3 | - | |
| 4 | -const IframeSubmit = function( form ) { | |
| 5 | - const iframeId = 'ajax-iframe-' + iframeCounter; | |
| 6 | - let $iframe = $( 'form[name="' + iframeId + '"]' ); | |
| 7 | - | |
| 8 | - if ( ! $iframe.length ) { | |
| 9 | - $iframe = $( '<iframe />' ).appendTo( document.body ).attr( { | |
| 10 | - name: iframeId, | |
| 11 | - src: '#', | |
| 12 | - } ); | |
| 13 | - } | |
| 14 | - | |
| 15 | - $( form ).on( 'submit', function() { | |
| 16 | - const $form = $( form ).clone().appendTo( document.body ); | |
| 17 | - | |
| 18 | - $form.attr( 'target', iframeId ); | |
| 19 | - $form.find( '#submit' ).remove(); | |
| 20 | - | |
| 21 | - return false; | |
| 22 | - } ); | |
| 23 | - | |
| 24 | - iframeCounter++; | |
| 25 | -}; | |
| 26 | - | |
| 27 | -export default IframeSubmit; | |
| 1 | +let iframeCounter = 1; | |
| 2 | +const $ = window.jQuery || jQuery; | |
| 3 | + | |
| 4 | +const IframeSubmit = function( form ) { | |
| 5 | + const iframeId = 'ajax-iframe-' + iframeCounter; | |
| 6 | + let $iframe = $( 'form[name="' + iframeId + '"]' ); | |
| 7 | + | |
| 8 | + if ( ! $iframe.length ) { | |
| 9 | + $iframe = $( '<iframe />' ).appendTo( document.body ).attr( { | |
| 10 | + name: iframeId, | |
| 11 | + src: '#', | |
| 12 | + } ); | |
| 13 | + } | |
| 14 | + | |
| 15 | + $( form ).on( 'submit', function() { | |
| 16 | + const $form = $( form ).clone().appendTo( document.body ); | |
| 17 | + | |
| 18 | + $form.attr( 'target', iframeId ); | |
| 19 | + $form.find( '#submit' ).remove(); | |
| 20 | + | |
| 21 | + return false; | |
| 22 | + } ); | |
| 23 | + | |
| 24 | + iframeCounter++; | |
| 25 | +}; | |
| 26 | + | |
| 27 | +export default IframeSubmit; | |