2010-11-24 8 views
6

インターネット エクスプローラでjQuery UIダイアログを自動サイズ調整するにはどうすればよいですか?自動サイズjQuery UIダイアログ(Internet Explorer)

このコードはFirefoxではOKですが、インターネット  ExplorerではOKです。

$('#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です。

+0

どのバージョンのjQueryとjQuery UIを使用していますか? –

+0

jquery ui 1.8.5 JQuery 1.4.2 – Shahin

答えて

0

最初

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

IEはそれを聞いてトリック(そのおそらく良いをした場合を見てみましょうすべてのオプションが,

経由で閉鎖されることを期待する次の行の末尾に,を追加してください。 IEのどのバージョンがこれに失敗していますか?)

+0

私はIE 8 – Shahin

+0

を使用していますが、上記の推奨に基づいていますか? –

+0

はいJQueryダイアログが正しく動作しません – Shahin

5

width: 'auto'サイジングjQuery UIダイアログで、次の「パッチ」(IE用)を使用して成功しています:

「自動」を、私はただ生きることができませんでした:
(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に応じて、我々は幅を使用すべきではない

注このコードを読み込みますそれなし... :)

+0

私は試しました。私はこのコードをjQuery-ui.jsの後に追加しましたが、まだ動作しません:(IE8 – Shahin

+1

私はそれがうまくいきませんでした - 私は 'dialog.innerWidth()' 'fixDialogAutoWidth'で... – kares

関連する問題