use boolean
// Double click to open Modal Dialog Window
$('#userAddedCard').dblclick(function (e) {
$currentTarget = $(e.target);
$('#modalDialog').dialog({
modal: true,
height: 600,
width: 500,
position: 'center',
buttons: {
Save: function () { //submit
save(true);
},
Cancel: function () { //cancel
cancel(true);
}
}
});
});
var boolean = false;
function save() {
var val = $("#customTextBox").val();
$currentTarget.find(".ctb").val(val);
$currentTarget.find(".date").val($("#datepicker").val());
boolean = true;
}
function cancel() {
if(!boolean){
$('#dialog-confirm').dialog({
resizable: false,
height: 300,
modal: true,
draggable: false,
buttons: {
YES: function () {
$(this).dialog("close");
$('#modalDialog').dialog("close");
},
Cancel: function () {
$(this).dialog("close");
}
}
});
}
else{
$('#dialog-confirm').hide();
}
}
when you click on cancel it display pup-up and when you click it on after save click on save button its hide.