Sha*_*hin 6 jquery jquery-ui autosize jquery-ui-dialog
如何在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(); } }
});
Run Code Online (Sandbox Code Playgroud)
我的HTML元素是DIV.
我正在width: 'auto'使用以下"补丁"(对于IE)调整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);
Run Code Online (Sandbox Code Playgroud)
加载jquery-ui.js后加载此代码...
请注意,根据票http://dev.jqueryui.com/ticket/4437我们不应该用宽度:"自动",但我不能没有它... :)
请先,在以下行末尾添加一个
buttons: { "close": function () { $(this).dialog("close"); document.getElementById("<%=btnnew.ClientID%>").click(); } }
Run Code Online (Sandbox Code Playgroud)
IE 希望通过以下方式关闭所有选项,
让我们看看这是否能解决问题(最好问问是在哪个版本的 IE 上出现此问题?)
| 归档时间: |
|
| 查看次数: |
16980 次 |
| 最近记录: |