Reputation: 21
I have the following java script code
function showDialog() {
$("#dialog").dialog({
autoOpen : true, height : '325', width : 'auto', modal : true, closeOnEscape : false,
});
$("#dialog").dialog('option', 'title', "Manage Questions");
$("#dialog").dialog('option', 'show', 'drop');
$("#dialog").dialog('option', 'resizable', true)
var strHtml = <MyCode>;
$("#dialog").html(strHtml);
$("#dialog").html();
$("#dialog").dialog('open');
}
when I call showDialog first time it works fine. but after that when user click on button that calls this function, the dialog appears then automatically disappear, if user clicks again it works fine, in other words First time it works fine, then user have to click twice to make it work.
Upvotes: 0
Views: 72
Reputation: 28523
You have not added any button for closing dialog, please add below code for closing dialog first and then open it.
$("#dialog").dialog("close");
your code should be like below
function showDialog() {
//close dialog
$("#dialog").dialog("close");
$("#dialog").dialog({
autoOpen : true, height : '325', width : 'auto', modal : true, closeOnEscape : false,
});
$("#dialog").dialog('option', 'title', "Manage Questions");
$("#dialog").dialog('option', 'show', 'drop');
$("#dialog").dialog('option', 'resizable', true)
var strHtml = <MyCode>;
$("#dialog").html(strHtml);
$("#dialog").html();
$("#dialog").dialog('open');
}
Upvotes: 1