I\'m currently using jquery to trap the submission of a form and show users a dialog for confirmation. If user clicks yes, then form should submit. If user clicks no, then c
Because when you submit the form, the submit event triggers again and so the event handler. You need to unbind the submit event handler when user says OK. Try this
$("#myform").submit(function (event) {
if (something) {
var $dialog = $('').dialog({
buttons: {
"OK": function () {
$dialog.dialog('close');
//Check this line - unbinding the submit event handler
$("#myform").unbind('submit').submit();
return;
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$dialog.dialog('open');
event.preventDefault();
return false;
} else {
$("#myform").submit();
}
});