Skip to content
Snippets Groups Projects
Unverified Commit 9df1988f authored by mattwire's avatar mattwire Committed by GitHub
Browse files

Merge pull request #8 from progressivetech/avoid-timing-problems

ensure our js code always runs first
parents 7bcf0cee 179da37b
No related branches found
No related tags found
No related merge requests found
......@@ -141,8 +141,28 @@
});
$submit.click( function() {
// Take over the click function of the form.
debugging('clearing submit-dont-process');
$form.data('submit-dont-process', 0);
// Run through our own submit, that executes Stripe submission if
// appropriate for this submit.
var ret = submit(event);
if (ret) {
// True means it's not our form. We are bailing and not trying to
// process Stripe.
// Restore any onclickAction that was removed.
$form = getBillingForm();
$submit = getBillingSubmit();
$submit.attr('onclick', onclickAction);
$form.get(0).submit();
return true;
}
// Otherwise, this is a stripe submission - don't handle normally.
// The code for completing the submission is all managed in the
// stripe handler (stripeResponseHandler) which gets execute after
// stripe finishes.
return false;
});
// Add a keypress handler to set flag if enter is pressed
......@@ -180,23 +200,6 @@
$form.find("input#cvv2").val('');
}
// Intercept form submission.
$form.on('submit', function(event) {
var ret = submit(event);
if (ret) {
// True means it's not our form. We are bailing and not trying to
// process Stripe.
// Restore any onclickAction that was removed.
$form = getBillingForm();
$submit = getBillingSubmit();
$submit.attr('onclick', onclickAction);
$form.get(0).submit();
return true;
}
// Otherwise, this is a stripe submission - don't handle normally.
return false;
});
function submit(event) {
event.preventDefault();
debugging('submit handler');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment