I am, trying to replicate the 'confirm' box of javascript using jquery dialog. This is my code,
function customConfirm(customMessage) {
$("#popUp").html(customMessage);
$("#popUp").dialog({
resizable: false,
height: 240,
modal: true,
buttons: {
"OK": function () {
$(this).dialog("close");
alert(true);
return true;
},
Cancel: function () {
$(this).dialog("close");
alert(false);
return false;
}
}
});
}
But when I tried to alert this method, it shows 'undefined'. It is not waiting for the popup to display. How can i make this customConfirm function to wait for the users input(ok/cancel)?. My need is that, customConfirm() method will return either true of false according to user input.
$.when()
. Found that the variable got passed before$.when()
completed. Any suggestions or advice? – Glabrate