Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ui - Nested Dialog z-index issues

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 :)

like image 718
shennyL Avatar asked Dec 02 '11 08:12

shennyL


1 Answers

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');
        }
    });
like image 189
tobias86 Avatar answered Oct 01 '22 20:10

tobias86