Reputation: 24729
I have a "delete" button and on clicking cancel on the confirm box, it still submits the form. What is the best way to stop the form submitting given that these two event functions apply to the same button?
The attribute data-confirm contains the confirm message.
$(document).on('click', "[data-confirm]",
(function () { return confirm($(this).attr('data-confirm')); }));
$(document).on("click", "input[type='submit'], button", buttonSubmit);
Here is the function buttonSubmit
with custom code ommitted.
var buttonSubmit = (function (e)
{
e.preventDefault();
//...
$(this).closest('form').submit();
});
Given a cancellation of confirm, how can i prevent buttonSubmit
code from executing?
Upvotes: 0
Views: 75