I am trying to create a function like window.confirm which can be used like this :
if (I.confirmDialog.open("Do you really want to Cancel")) {
// do this
}
else {
// do this
}
I am writing the pop-up function like this :
I.confirmDialog = {
open: function(confirmMsg) {
var $modal = I.modals.new("small confirm-dialog");
$modal.find("h1").text(confirmMsg);
$modal.append("<div class=\"action-wraper\"><a class=\"action-yes\" href=\"javascript:void(0);\">Yes</a><a class=\"action-no\"href=\"javascript:void(0);\">No</a></div>");
I.modals.open($modal);
$modal.find(".action-yes").click(function() { I.modals.close(); /* return true will not work*/ });
$modal.find(".action-no").click(function() { I.modals.close(); /* return false will not work*/ });
}
};
But the problem is I am unable to return true or false from the I.confirmDialog.open(). execution of I.confirmDialog.open() function doesn't wait for button click and the return from click callback doesn't affect the return value of I.confirmDialog.open().
I would like to know how window.confirm is written if possible