So, I wrote a function to emulate the functionality of JavaScript
confirm
box.
How to make a function not return until a specific task has been accomplished? Here mconfirm
returns undefined
. I want to return true
or false
based upon the user clicked Yes
/Cancel
. How could I do this?
var mconfirm = function(message) {
if(!message)
message = "Remove the selected item?";
$("#dialog-confirm").html('<span class="glyphicon glyphicon-alert" id="confirm-alert-ico"></span> ' + message);
$( "#dialog-confirm" ).dialog({
resizable: false,
modal: true,
buttons: {
Yes: function() {
$( this ).dialog( "close" );
return true;
},
Cancel: function() {
$( this ).dialog( "close" );
return false;
}
}
});
};