JSFiddle - React, Tailwind, and code Playground
by mgibsonbr
HTML
<form id="myform" action="/echo/html/?html=;delay=3;" method="post">
<input type="submit"/>
</form>
<div id="dialog"></div>
JavaScript
var userConfirmed = false;
$("#myform").submit(function(e) {
if ( userConfirmed ) {
userConfirmed = false;
return true;
}
// lots of these
if (false) {
return false;
}
// popup the dialog confirmation
$("#dialog").dialog({
buttons: {
"Ok": function() {
userConfirmed = true;
$(this).dialog("close");
$("#myform").submit();
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$("#dialog").dialog("open");
e.preventDefault();
return false;
});