且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用jQuery对话框UI修复zIndex问题

更新时间:2023-02-22 14:57:08

在jQuery UI 1.9中,我花了很长时间来解决这个问题.最终,我选择了这种蛮力的方法来为我的模式对话框设置z-index.

I spent far too long grappling with this issue in jQuery UI 1.9. Eventually I settled on this somewhat brute force approach to setting the z-index for my modal dialogs.

$('#dialog').dialog({
    modal: true,
    zIndex: 25,
    stack: false,
    open: function (event, ui) {
        $('#dialog').parent('.ui-dialog').css('zIndex', 26)
            .nextAll('.ui-widget-overlay').css('zIndex', 25);
    }
});

您可能需要在open事件中进行DOM遍历,以正确选择叠加层;如果不使用模式对话框,则可以忽略它,但这给了我很好的可靠结果.

You may need to play with the DOM traversal in the open event to properly select your overlay, or omit it if you are not using a modal dialog, but this has given me good reliable results.