Last active
July 30, 2017 01:13
-
-
Save tommaitland/9904540 to your computer and use it in GitHub Desktop.
Code to provide callbacks and override how NationBuilder processes signups through AJAX
This file contains 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
$(formSelector).submit( function(event) { | |
// Store the original NB function in a temp variable | |
var tmp = window.NB.EventHub.dispatch; | |
/** | |
* $(this) / $form is the entire signup form. onsubmit changes can be made by finding inputs/children | |
* | |
* ie. $form.find('input[type="submit"]').val('Loading'); | |
* | |
**/ | |
$form = $(this); | |
// Override the NB function | |
window.NB.EventHub.dispatch = function(e) { | |
if (e == 'form.success') { | |
// success | |
} else { | |
// error | |
} | |
// Restore the original NB function so things keep working | |
window.NB.EventHub.dispatch = tmp; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment