jQuery对话框在IE7中出现问题

3

我在处理IE7中标题栏的宽度时遇到了问题。当使用width: 'auto'打开第一个对话框函数时,标题栏不会延伸到整个对话框窗口。使用minWidth的第二个函数有效,但更像是width属性而不是随内容增长的大小。有什么想法吗?

不起作用:

        $(dialogId).dialog({
            autoOpen: 'false',
            modal: true,
            draggable: false,
            resizable: false,
            buttons: buttons,
            title: title,
            width: 'auto',
            open: function(){
                /* IE HACK */
                $buttonPane = $(this).next();
                $buttonPane.find('button:first').addClass('accept').addClass('action');
                $('.ui-dialog-titlebar-close').hide();
                $('.ui-dialog').addClass('open_dialog');
                $(this).css('overflow','hidden');// IE hack
                onOpen;
            },
            close: function(){
                $('.ui-dialog').removeClass('open_dialog');
                afterClose;
            }
        });

工作(仅限固定宽度):

        $('#conf_dialog').dialog({
            dialogClass: dialogclass,
            autoOpen: 'false',
            modal: true,
            draggable: false,
            resizable: false,
            buttons:buttons,
            title:title,
            minWidth: 255,
            open: function(){
                /* IE HACK */
                $buttonPane = $(this).next();
                $buttonPane.find('button:first').addClass('accept').addClass('action');
                $('.ui-dialog-titlebar-close').hide();
            },
            close: afterClose
        });

2个回答

2
理论上,width:auto不被支持,但在IE8和FF中似乎可以工作,但在IE7上不行。
我遇到了这个链接:

http://ovaraksin.blogspot.com/2011/05/jquery-ui-dialog-with-auto-width-and.html

并做出了如下的调整:
       $("#myDialog").dialog({ autoOpen: false,
            width: 'auto',
            height: 'auto',
            modal: true,
            title: 'ABC...' 
        }).bind("dialogopen", function (event, ui) {

            // fix for width:auto in IE  
            var contentWidth = $(this).width();
            $(this).parent().find('.ui-dialog-titlebar').each(function () {
                $(this).width(contentWidth);
            });

        }).bind("dialogclose", function (event, ui) {
            //fix for width:auto in IE 
            $(this).parent().css("width", "auto"); 
        });

1
如果您根本不定义宽度会发生什么? 您尝试过width: 100%吗?

设置宽度为100%只是将对话框扩展到整个窗口。不定义宽度也没有帮助... - Jules

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接