Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a dialog using jquery-ui without html div specified

Using jquery-ui to create a dialog is pretty easy:

<script>
$(function() {
    $( "#dialog" ).dialog();
});
</script>

<div id="dialog" title="Basic dialog">
    <p>This is the default dialog which is useful for displaying information. The dialog window can be   moved, resized and closed with the 'x' icon.</p>
</div>

...but one still needs a div in the HTML for this to work. In Dojo:

var dlg = new dijit.Dialog({
    title:"dialog",
    style: "width:30%;height:300px;"
});
dlg.show();

would just do the trick without anything specified in the html section, can jquery-ui do this? (I have to use jquery-ui here) Thanks,

David

like image 458
David Zhao Avatar asked Sep 02 '11 16:09

David Zhao


1 Answers

While I'm not sure why you would want to open a dialog with no content, you could easily create a new one on the fly and invoke the jquery dialog against it:

$("<div>hello!</div>").dialog();
like image 122
Justin Beckwith Avatar answered Oct 14 '22 10:10

Justin Beckwith