Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling the DOM location of a jquery UI dialog

I'm trying to create a jQueryUI Dialog and have it insert itself into the dom within a specific element. We have a content section that is the parent of a number of styles so items within the dialog are not styled since jqueryUI does an append to body. Is there a way to tell jqueryUI to append to a selector of my choosing?

What it does

<section id="content">
</section>
<div class="dialog"> the dialog </div>

what I want

<section id="content">
<div class="dialog"> the dialog </div>
</section>
like image 787
dstarh Avatar asked Jan 19 '12 20:01

dstarh


People also ask

What is jQuery ui dialog?

The jQuery UI dialog method is used to create a basic dialog window which is positioned into the viewport and protected from page content. It has a title bar and a content area, and can be moved, resized and closed with the 'x' icon by default. Syntax: You can use the dialog ()method in two forms: $(selector, context).

How do you check if jQuery dialog is initialized?

dialog( { ... } ); Then check for the class when needed: if ($("selector"). hasClass("initialized")) { ... }


1 Answers

I know this question is a little old but I wanted to make sure any new comers were pointed in the right direction. The option "appendTo" was added in version 1.10.0.

$( ".selector" ).dialog({ appendTo: "#someElem" });

You can read about it here

like image 85
testing123 Avatar answered Oct 13 '22 01:10

testing123