I got a dialog which showing a table, and when i click on a "Delete" button, I will pop up another dialog to ask for confirmation. Currently this works fine at the first time, but if I click the "Delete" button for the second time, the delete dialog is shown behind the first table dialog, so it is actually invisible to the user.
I tried to set the z-index for both dialog, but I don't know why it is only working at the first time
Following is the sample of my script:
// The 1st dialog
var $detaildialog = $('#tableplaceholder').dialog({
autoOpen: false,
modal: true,
width: '800',
height: 'auto'
});
// Some steps to set the url.. then open the dialog
$detaildialog.load(url, function () {
$('#loading').hide();
$detaildialog.dialog('open');
});
// Then, when delete action is called, open the second dialog
fnOnDeleting: function (tr, id, fnDeleteRow) {
var $dialog = $('#checkdeletedialog').dialog({
autoOpen: false,
modal: true,
title: 'Delete Confirmation',
zIndex: 90000
});
$dialog.dialog('open');
}
Anything I am doing wrong here?
Appreciate any help.. thanks :)
Set the "stack" property of the second dialog to true.
function (tr, id, fnDeleteRow) {
var $dialog = $('#checkdeletedialog').dialog({
autoOpen: false,
modal: true,
stack: true,
title: 'Delete Confirmation'
});
$dialog.dialog('open');
}
More information here.
EDIT: We've also had issues with modal dialogs behaving oddly after opening once. We found that 'destroying' the dialog when it closes fixes the issue, e.g.
var $dialog = $('#checkdeletedialog').dialog({
autoOpen: false,
modal: true,
stack: true,
title: 'Delete Confirmation',
close: function() {
$(this).dialog('destroy');
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With