I am trying to call the below method twice, first time the dailogue opens and i click on yes button in the dialogue, when i make the second call, the control directly hits Close method, without showing the dialogue on the screen.
Kindly help
function ConfirmWindow(title, msg, showOkButton) {
//debugger
var defer = $.Deferred();
$($('#ConfirmWindow')).dialog({
// modal: true,
title: title,
height: 175,
width: 440,
resizable: false,
closeOnEscape: true,
draggable: false,
open: function() {
var markup = msg;
$(this).html(markup);
$(this).closest(".ui-dialog")
.find(".ui-dialog-titlebar-close")
.removeClass("ui-dialog-titlebar-close")
.html("<span class='ui-button-icon-primary ui-icon ui-icon-closethick'></span>");
$(this).closest(".ui-dialog").find(".ui-widget-header")
.addClass("ConfirmHeaderClass");
$(this).parent().css("zIndex", 2000);
if (!showOkButton)
$('.ui-dialog-buttonpane button:contains("Ok")').button().hide();
else {
$('.ui-dialog-buttonpane button:contains("Yes")').button().hide();
$('.ui-dialog-buttonpane button:contains("No")').button().hide();
$('.ui-dialog-buttonpane button:contains("Cancel")').button().hide();
}
},
close: function() {
defer.resolve("cancel");
$(this).dialog('close');
},
buttons: {
Yes: function() {
defer.resolve("yes");
$(this).dialog("close");
},
No: function() {
defer.resolve("no");
$(this).dialog("close");
},
Cancel: function() {
defer.resolve("cancel");
$(this).dialog("close");
},
Ok: function() {
defer.resolve("ok");
$(this).dialog("close");
},
}
});
//debugger
return defer.promise();
}