Closed aaronlcope closed 12 years ago
At this moment it's not possible to add nodes dynamically to the tree. I think it would be a nice feature, though.
It is possible to load a whole new tree using the function loadData (http://mbraak.github.com/jqTree/#functions-loadData).
The 'dev' branch contains a new feature for loading a subtree. The function 'loadData' now accepts a 'parent_node' parameter.
$tree.tree('loadData', data, parent_node);
Example for loading subtree on click:
$('#tree1').bind(
'tree.click',
function(e) {
var node = e.node;
$.getJSON(
'/get-data/',
function(data) {
$tree.tree('loadData', data, node);
}
);
}
);
Implemented in version 0.7
There is still an issue here. 'tree.click' event won't be always triggered. For example, if you try to move a node to inside a closed node, it will open the node but won't trigger the 'tree.click' event.
I'll create a separate issue since this was already closed.
I don't see a way to append new data to an existing node when you click it. Is there a way to issue an ajax request for more data under a particular node and have this plugin append more nodes via JSON formatted responses?
If this already exists, is there any sample code anywhere?