Binding to the click event of a submit button, will our JS run before the
form submits?
We are currently binding to the click event of a submit button (there are
reasons why we are not binding to the submit event for the form). Is it
guaranteed that our JS will run before the form submits (as we are
entering values into hidden fields that we want to submit) or do we need
to prevent the form from submitting and then call the submit again?
$(function() {
$('#button').on('click', function() {
// Do some stuff here - needs to finish before the form submits
return true;
});
});
Thanks in advance!
No comments:
Post a Comment