Last active
July 9, 2018 21:23
-
-
Save timersys/c1ed53aada37992d45069f0710e15e9e to your computer and use it in GitHub Desktop.
Open popup after ninja forms submission - More on https://timersys.com/how-to-display-a-popup-after-user-submits-form/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // don't add this tag | |
// Print javascript code in the footer of the site to trigger the popup upon form submission | |
add_action('wp_footer', 'add_popups_trigger_code',150 ); | |
function add_popups_trigger_code(){ | |
// show code on certain page, comment out to print code on every page | |
if( ! is_page('520') ) | |
return; | |
?> | |
<script> | |
// Create a new object for custom validation of a custom field. | |
var myPopupsSubmitController = Marionette.Object.extend( { | |
initialize: function() { | |
this.listenTo( Backbone.Radio.channel( 'forms' ), 'submit:response', this.actionSubmit ); | |
}, | |
actionSubmit: function( response ) { | |
//insert popup ID here | |
SPU.show('529'); | |
}, | |
}); | |
// On Document Ready... | |
jQuery( document ).ready( function( $ ) { | |
// Instantiate our custom field's controller, defined above. | |
new myPopupsSubmitController(); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment