Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


JQuery Dialog not opening second time
I had a JQuery dialog that worked fine, until I moved it to a nested directive in angular; then it worked every time except the second open which showed no content.
This was a reusable dialog I was opening using 'dialog({dialog info})'.

The fix was to check if this was the first time opening it, and if so, open using '.dialog({dialog info})' and keep a reference to the dialog... and any later time opening it, use '.dialog('open') without rebuilding it:

if (controller.addDialog) {
controller.addDialog.dialog('open');
}
else {
controller.addDialog = $("#MYDIV");
controller.addDialog.dialog({
modal: true,
title: "title",
minWidth: 500,
buttons: [{
text: "Add",
click: function () {
controller.appendNewIds($(this));
}
},
{
text: "Cancel",
click: function () {
$(this).dialog("close");
}
}]
});
}

Created By: amos 10/8/2018 10:58:07 AM