I am using JQuery & JQuery UI and I tried using JQuery UI Dialog to solve this problem but I was unable to accomplish it.
Basically I have for example this code that uses JS confirm box:
// if user presses cancel, do not proceed to the next section of the code
if ( ! confirm('Are you sure you want to press OK?')) {
return;
}
.... Lots of code below
I want to turn this to use a custom box that I can customize using CSS. I tried with UI dialog:
function confirmIt(text) {
$('#confirm_dialog').dialog({
width: 300,
height: 150,
buttons: {
"OK": function() { return true; },
"Cancel": function() { return false; }
}
});
}
if ( ! confirmIt('Are you sure you want to press OK?')) {
return;
}
.... Lots of code below
Now the problem with above code is that a lot of code below the if condition still executes. I understand that JQuery Dialog is aync process, but I was wondering if there are such plugins for free out there that I could use that will return boolean value? Basically functionality wise it should work exactly same as JS confirm()
. I do not want to wrap that a lot of code within the callback of JQuery UI dialog to achieve this. I just want to stop script execution if CANCEL is clicked
and continue execution if OK is clicked
.