Reputation: 6032
I have a div:
<div id="dialog">Dialog content here</div>
I have a function:
function process() {
$("#dialog").dialog({autoOpen:false});
}
I make the dialog only if it is not already created. How can I do that?
Upvotes: 0
Views: 49
Reputation: 1449
Just put $("#dialog").dialog({autoOpen:false});
into your document.ready()
event. Finally, in your process()
function, add
$( "#dialog" ).dialog( "open" );
Upvotes: 0
Reputation: 48793
Check the data
. If the dialog is created on the element, then it has 'dialog' as a property of the data
:
function process()
{
if( !$('#dialog').data('dialog') ){
$("#dialog").dialog({autoOpen:false});
}
}
Upvotes: 3