【问题标题】:jQuery dialog IE7 issuesjQuery 对话框 IE7 问题
【发布时间】:2010-10-26 23:06:07
【问题描述】:

我只在 IE7 中遇到了标题栏宽度的问题。使用宽度打开时的第一个对话框功能:'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
        });

【问题讨论】:

  • 你有没有运气解决这个问题?我遇到了完全相同的问题...
  • width:auto 不受支持:bugs.jqueryui.com/ticket/4437 如果您查看 API 文档,宽度专门只接受数字类型而不是字符串/'auto'。对于遇到此问题的其他人,如果您尝试使用 width:auto,则必须扩展/绑定到事件以自行调整标题大小。

标签: jquery jquery-ui dialog modal-dialog titlebar


【解决方案1】:

理论上不支持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"); 
        });

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • Width 100% 只是将对话框扩展到整个窗口。不定义宽度也无济于事......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-28
    • 2011-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多