首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Internet Explorer中自动调整jQuery UI对话框的大小

问在Internet Explorer中自动调整jQuery UI对话框的大小
EN

Stack Overflow用户
提问于 2010-11-24 17:38:35
回答 2查看 17K关注 0票数 6

如何在Internet Explorer中自动调整jQuery UI对话框的大小?

此代码在Firefox中可以,但在Internet和Explorer中不可以。

代码语言:javascript
复制
$('#dialog2').dialog({
    autoResize: true,
    show: "clip",
    hide: "clip",
    height: 'auto',
    width: 'auto',
    autoOpen: false,
    modal: true,
    position: 'center',
    draggable: true,

    open: function (type, data) {
        $(this).parent().appendTo("form");

    },
    buttons: { "close": function () { $(this).dialog("close"); document.getElementById("<%=btnnew.ClientID%>").click(); } }
});

我的HTML元素是一个DIV。

EN

回答 2

Stack Overflow用户

发布于 2010-12-15 04:54:51

我使用以下“补丁”(用于IE)成功地调整了width: 'auto'的jQuery UI对话框的大小:

代码语言:javascript
复制
(function($) {
var fixDialogAutoWidth = $.noop;
if ( $.browser.msie ) {
    fixDialogAutoWidth = function(content) {
        var dialog = $(content).parent('.ui-dialog');
        var width = dialog.innerWidth();
        if ( width ) dialog.css('width', width);
    }
}

var _init = $.ui.dialog.prototype._init;
$.ui.dialog.prototype._init = function() {
    // IE magick: (width: 'auto' not working correctly) :
    // http://dev.jqueryui.com/ticket/4437
    if ( this.options.width == 'auto' ) {
        var open = this.options.open;
        this.options.open = function() {
            fixDialogAutoWidth(this);
            if ( open ) open.apply(this);
        }
    }
    // yet another bug options.hide: 'drop' does not work
    // in IE http://dev.jqueryui.com/ticket/5615
    if ( $.browser.msie && this.options.hide == 'drop' ) {
        this.options.hide = 'fold';
    }
    return _init.apply(this); // calls open() if autoOpen
};
})(jQuery);

只需在jquery-ui.js加载之后加载此代码...

请注意,根据票证宽度,我们不应该使用宽度:‘http://dev.jqueryui.com/ticket/4437’,但我就是不能没有它... :)

票数 5
EN

Stack Overflow用户

发布于 2010-11-25 00:21:59

请先在下面一行的末尾添加,

代码语言:javascript
复制
buttons: { "close": function () { $(this).dialog("close"); document.getElementById("<%=btnnew.ClientID%>").click(); } }

IE期望通过,关闭所有选项

让我们看看这样做是否有效(问一下这是在哪个版本的IE上失败的可能是好的)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4265316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档