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

Jquery plugins 如何使用jQuery对话框UI修复zIndex问题,jquery-plugins,z-index,jquery-dialog,Jquery Plugins,Z Index,Jquery Dialog,我对对话框UI有一个小问题。我将zIndex值标记为高数值,但它似乎忽略了它 下面是我的代码 $( "#number-add" ).dialog({ resizable: false, width: 500, modal: false, autoOpen: false, stack: false, zIndex: 9999,

我对对话框UI有一个小问题。我将zIndex值标记为高数值,但它似乎忽略了它

下面是我的代码

        $( "#number-add" ).dialog({
            resizable: false,
            width: 500,
            modal: false,
            autoOpen: false,
            stack: false,
            zIndex: 9999,
            buttons: {
            "Add Contact": function(e) {

            var formData = $('#number-add-form').serialize();

            //submit record
            $.ajax({    
                type: 'POST',
                url: 'ajax/handler-add-new-account-number.php',     
                data: formData,
                dataType: 'json',
                cache: false,
                timeout: 7000,
                success: function(data) {           

                    $('#responceAddNumber').removeClass().addClass((data.error === true) ? 'errorBox' : 'passBox').html(data.msg).fadeIn('fast');   

                    if ($('#responceAddNumber').hasClass('passBox')) {
                        $('#responceAddNumber').fadeIn('fast');
                        $('#add-form').hide();              

                        window.location.reload();
                        setTimeout(function() {

                            $(this).dialog( "close" );                          
                        }, 1000);


                    }

                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {

                    $('#response-add').removeClass().addClass('errorBox')
                                .html('<p>There was an<strong> ' + errorThrown +
                                      '</strong> error due to a<strong> ' + textStatus +
                                      '</strong> condition.</p>').fadeIn('fast');           
                },              
                complete: function(XMLHttpRequest, status) {            
                    if (   $('#response-add').hasClass('passBox') ){
                        $('form')[0].reset();
                    }
                }
            }); 



            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }

        }
    });
$(“#编号添加”)。对话框({
可调整大小:false,
宽度:500,
莫代尔:错,
自动打开:错误,
堆栈:false,
zIndex:9999,
按钮:{
“添加联系人”:功能(e){
var formData=$(“#数字添加形式”).serialize();
//提交记录
$.ajax({
键入:“POST”,
url:'ajax/handler add new account number.php',
数据:formData,
数据类型:“json”,
cache:false,
超时:7000,
成功:函数(数据){
$('#responceadnumber').removeClass().addClass((data.error==true)?'errorBox':'passBox').html(data.msg).fadeIn('fast');
if($('responceadNumber').hasClass('passBox')){
$('responceadnumber').fadeIn('fast');
$('#add form').hide();
window.location.reload();
setTimeout(函数(){
$(此).dialog(“关闭”);
}, 1000);
}
},
错误:函数(XMLHttpRequest、textStatus、errorshown){
$('#response add').removeClass().addClass('errorBox'))
.html(“出现了一个”+错误+
“由于“”+文本状态而导致的错误+
“条件。

”).fadeIn('fast'); }, 完成:函数(XMLHttpRequest,状态){ if($('#response add').hasClass('passBox')){ $('form')[0].reset(); } } }); }, 取消:函数(){ $(此).dialog(“关闭”); } } });
我将堆栈值设置为false,将zIndex设置为9999。我在这里做错了什么让zIndex不起作用?我正在使用jQueryUIDialog 1.10.2


感谢您的帮助。

看起来像是应用了
可调整大小:false
选项,这样就不会设置z索引工作所需的位置

设置
可调整大小:true
,将其删除,或将父级
ui对话框设置为具有
位置:绝对值

//after .dialog() call
$( "#number-add" ).parent(".ui-dialog").css({position:"absolute"});
.ui-dialog {
   position:absolute;
}
或者设置css样式,使ui对话框具有
position:absolute

//after .dialog() call
$( "#number-add" ).parent(".ui-dialog").css({position:"absolute"});
.ui-dialog {
   position:absolute;
}

虽然不确定这种总体风格将如何影响jQuery UI对话框的功能

看起来,应用
可调整大小:false
选项可以使其不设置z-index工作所需的位置

设置
可调整大小:true
,将其删除,或将父级
ui对话框设置为具有
位置:绝对值

//after .dialog() call
$( "#number-add" ).parent(".ui-dialog").css({position:"absolute"});
.ui-dialog {
   position:absolute;
}
或者设置css样式,使ui对话框具有
position:absolute

//after .dialog() call
$( "#number-add" ).parent(".ui-dialog").css({position:"absolute"});
.ui-dialog {
   position:absolute;
}

虽然不确定这种总体风格将如何影响jQueryUIDialog的功能,但我在jQueryUI1.9中花了太长时间来解决这个问题。最终,我决定采用这种有点暴力的方法来设置模态对话框的z索引

$('#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遍历来正确选择覆盖,或者如果不使用模式对话框,则忽略它,但这给了我很好的可靠结果。

我在jQuery UI 1.9中花了太长时间来解决这个问题。最终,我决定采用这种有点暴力的方法来设置模态对话框的z索引

$('#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遍历来正确选择覆盖,或者如果您不使用模式对话框,则忽略它,但这给了我很好的可靠结果。

谢谢您的帮助。我已将大小调整为:false,但这并没有解决问题。我还能试什么?谢谢你的帮助。我已将大小调整为:false,但这并没有解决问题。“我还能尝试什么呢?”布莱克的回答对我来说也是一种行之有效的方法——但是打字错误。css('zIndex',…)应该是。css('z-index',…)@Blake的回答对我来说也是一种有效的方法——但是打字错误。css('zIndex',…)应该是.css('z-index',…)