5

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

1 Answer 1

6

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');
        }
    });
Sign up to request clarification or add additional context in comments.

6 Comments

Hi, i tried and its not working.. any other idea? Thanks a lot
Try not specifying the z-index in conjunction with the stack: true option
Also consider 'destroying' the dialog once you're done with it. See edited answer.
Hi, the 'destroy' does the trick! But I do need to include the destroy in every place wherever possible, cause if I only include it in the close function, the close triggered by submit is not calling the destroy... anyway, really thanks a lot!
Thanks so much!! modal: true, stack: true did the trick for me.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.