Bahdeng Bahdeng - 1 year ago 111
Javascript Question

Dynatree does not reload with new nodes programatically

I am loading the dynatree programitically when the page loads as follows

function loadTree(data)
var rootNode = $("#tree").dynatree("getRoot");
$.each(data, function () {
var childNode = rootNode.addChild({
title: this.agent_code + ' - ' + this.holder_name,
tooltip: this.holder_name,
isFolder: true,

Now after i retrieve new data from the server and wants to load with new nodes it does not remove the old node.

function reload(data)

The above code removes only a single node. What am i missing here.
Thanks in advance

i tried with a workaround through the following code

function reload(data)
$('#test').html('<div id="tree"></div>');
$('#tree').dynatree(); //reinitialize the tree

It does reload but then cannot populate the child nodes through lazyloading


This will remove all the nodes that you have added during the initial load: