2011-12-08 93 views
0

如果在已經顯示對話框時打開對話框,則默認情況下,第二個對話框不會超出第一個對話框的寬度。即使第二個對話框實際上並未包含在第一個對話框中(我通過單擊第一個對話框中的鏈接來獲得第二個對話框),情況也是如此。jQueryUI:調整對話框中的對話框大小?

我可以在第二個對話框上設置明確的寬度,但這並不理想。我真的希望它能自動調整大小(比如第一個/背景對話框)的內容(quasipartikel multiselect)。如果在第二個對話框上有明確的寬度,我通常會得到兩組滾動條:一個在對話框本身上,另一個在內部多選列表中。

請注意,我只嘗試在JS .dialog()調用中使用顯式寬度來調整第二個對話框的大小,而不是通過css(我幾乎不知道)。

有沒有人有任何想法如何自動調整第二個對話框?謝謝。

編輯

一些代碼加入建議:

<div id="dialog-top" title="Tab data"> 
    <form> 
    ...lots of stuff, including id 'addCodeButton', which 
    ...pops up the second dialog 
    </form> 
</div> <!-- dialog-top --> 

<div id="dialog-add-code" title="Code selector"> 
    <select id = "codes" ...etc... > 
    ... 
    </select> 
</div> 

$(function(){ 
    $('#addCodeButton').click(function(){ 
     // problem: this 'open' will not set the width of the new dialog 
     // wider than 'dialog-top' unless an explicit width is given 
     // (see '460' below) 
     $('#dialog-add-code').dialog('open'); 
     return false; 
    }); 
}); 

var $dialog = $("#dialog-top").dialog({ 
    autoOpen: false, 
    modal: true, 
    buttons: { 
    ... 
    } 
}); 

$('#dialog-add-code').dialog({ 
    autoOpen: false, 
    width: 460, 
    modal: false, 
    buttons: { 
    ... 
    } 
}); 
+0

可能會提供一些代碼 –

回答

1

我不知道是什麼導致你的問題。這裏是小提琴演示,你想要什麼工作。

http://jsfiddle.net/brettzink/NASyR/

你試過.dialog({width:"auto"});

+0

Aaahh ...不,我沒有。如果我忽略寬度規格,我認爲它會是自動的。我只是把「自動」,它的作品。謝謝 - 對不起! – EML

+0

沒問題。樂於幫助! – BZink