如何在Internet Explorer中自动调整jQuery UI对话框的大小?
此代码在Firefox中可以,但在Internet和Explorer中不可以。
$('#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。
发布于 2010-12-15 04:54:51
我使用以下“补丁”(用于IE)成功地调整了width: 'auto'的jQuery UI对话框的大小:
(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’,但我就是不能没有它... :)
发布于 2010-11-25 00:21:59
请先在下面一行的末尾添加,
buttons: { "close": function () { $(this).dialog("close"); document.getElementById("<%=btnnew.ClientID%>").click(); } }IE期望通过,关闭所有选项
让我们看看这样做是否有效(问一下这是在哪个版本的IE上失败的可能是好的)。
https://stackoverflow.com/questions/4265316
复制相似问题