控制jquery UI对话框的DOM位置

dst*_*arh 10 jquery-ui jquery-ui-dialog

我正在尝试创建一个jQueryUI对话框,并将其插入到特定元素中的dom中.我们有一个内容部分,它是许多样式的父级,因此对话框中的项目没有样式化,因为jqueryUI会附加到正文.有没有办法告诉jqueryUI追加到我选择的选择器?

它能做什么

<section id="content">
</section>
<div class="dialog"> the dialog </div>
Run Code Online (Sandbox Code Playgroud)

我想要的是

<section id="content">
<div class="dialog"> the dialog </div>
</section>
Run Code Online (Sandbox Code Playgroud)

tes*_*123 13

我知道这个问题有点老了,但我想确保任何新来的人指向正确的方向.版本1.10.0中添加了"appendTo"选项.

$( ".selector" ).dialog({ appendTo: "#someElem" });
Run Code Online (Sandbox Code Playgroud)

你可以在这里阅读它


dst*_*arh 6

来自Custom CSS范围和jQuery UI对话框主题

// Create the dialog, but don't open it yet
var d = $('#myDialogContents').dialog({
    autoOpen: false
    // other dialog options
});
// Take whole dialog and put it back into the custom scope
d.parent('.ui-dialog').appendTo('.myCustomScope');
// Open the dialog (if you want autoOpen)
d.dialog('open');
Run Code Online (Sandbox Code Playgroud)