I have a form that, when submitted, I need to do some additional processing before it should submit the form. I can prevent default form submission behavior, then do my additional processing (it's basically calling Google Maps API and adding a few hidden fields to the form) -- and then I need the form to submit.
Is there a way to "prevent default", then some point later "continue default?"
submit(function(e){ e. preventDefault(); // Cycle through each Attendee Name $('[name="atendeename[]"]', this). each(function(index, el){ // If there is a value if ($(el). val()) { // Find adjacent entree input var entree = $(el).
There is no opposite method of event. preventDefault() to understand why you first have to look into what event. preventDefault() does when you call it. Underneath the hood, the functionality for preventDefault is essentially calling a return false which halts any further execution.
preventDefault() method stops the default action of an element from happening. For example: Prevent a submit button from submitting a form. Prevent a link from following the URL.
The preventDefault() method cancels the event if it is cancelable, meaning that the default action that belongs to the event will not occur. For example, this can be useful when: Clicking on a "Submit" button, prevent it from submitting a form. Clicking on a link, prevent the link from following the URL.
Use jQuery.one()
Attach a handler to an event for the elements. The handler is executed at most once per element per event type
$('form').one('submit', function(e) {
e.preventDefault();
// do your things ...
// and when you done:
$(this).submit();
});
The use of one
prevent also infinite loop because this custom submit
event is detatched after the first submit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With