I have two dialog boxes within my view. Each of these dialog boxes have ajax commands within them for instance the first one does a POST and second one does a LOAD.
The issue is after I select from a checkbox list in dialog box 1 and hit UpdatePage button, my model gets updated just fine. However, The second dialog box containing the tree view with another checbobox list/nodes will not toggle at all. It does retain its previous state though: The checkboxes selected previosuly are checked but it will not toggle at all.
The following function creates the dialog box 1 and upon successful completion of the post command in this dialog box that the second dialog box and the treeview within, will not toggle.
function initDailog() {
RunDialog = $("#runDatestreeview").dialog({ closeOnEscape: true, stack: false, autoOpen: true,
modal: false, resizable: true, draggable: true, title: 'Select Run Dates to Auto-Populate Form Fields & Test Exceptions:',
width: 600, height: 500, position: 'center',
open: function (type, data) {
},
buttons: { UpdatePage: function () {
//storing the value of treeview selections in dialog box 2
var originalContent = $("#treeview").html();
$.post(runDatesUrl,
$("#form").serialize(),
function (data) {
$("#runDatestreeview").remove();
//removing the div which contains the treeview
$("#treeview").remove();
$("#testExceptiontreeview").remove();
$("#main").html(data);
//setting back the value of the div which contains the treeview
$("#treeview").html(originalContent);
}, "html");
},
Cancel: function () {
$(this).dialog("close");
}
}
});
RunDialog.closest("div.ui-dialog").appendTo("#form");
}
Treeview defined in dialog box 2, in its seperate JS file:
$("#errorCodes ul").treeview({
collapsed: true,
prerendered: false
});
The HTML for The div which contains the tree view:
<div id="treeview" title="Dialog Title" style="font-size: 10px; font-weight: normal;
overflow: scroll; width: 800px; height: 450px; display: none;">
<div id="errorCodes">
@Html.RenderTree(CacheHelper.ErrorCodes(), ec => ec.Name, ec => ec.Children.ToList(), ec => (ec.ID).ToString(), null, "e")
</div>
<div id="inputReps" style="display: none;">
</div>
</div
$("#errorCodes ul")which stops working? If so, is$("#errorCodes ul")element part of theoriginalContentor within any of the HTML elements you remove with one of the.remove()calls? If that is the case you might need to re-bind the treeview again. When you remove an element from the DOM all it's events are removed too. Even if you re-add it it is not the same but now a new element, therefore you would have to re-bind the treeview. You might be able to solve this with.clonebut that depends on what your response details.#errorCodes ul,#treeview, etc.