I'm using Martin Wendt's Dynatree and want to update the tree in Ajax, dynamically and recursively.
For this, I'm using functions like tree.getNodeByKey(nodes[i-1]).appendAjax({});
and tree.activateKey(nodes[i]);
in a for
loop.
When adding alert("Hello world");
into the loop, my code works correctly 95% or the time. Without it, the code never works.
The problem is obviously coming from the fact that Dynatree is performing its Ajax requests in asynchronous mode, and seem ignoring the async:false
, when added to .initAjax
and/or .appendAjax
:
jQuery('#tree').dynatree("getTree").getNodeByKey(nodes[i-1]).appendAjax({
type: 'POST',
url: "inc/treeNodes.php",
dataType: 'json',
data: {key: nodes[i]},
async:false
});
I tried adding setTimeout (function() {},2000);
around the call to .appendAjax
, but it prevented this method to work.
Could Dynatree be modified to support asynchronous mode?