问题
I am using below code while page load to generate a tree using jsTree.
$('#jstree_demo_div').jstree({
'core': {
'themes': {
'name': 'proton',
'responsive': true
},
'data': results,
"check_callback" : true
}
});
All is working fine and results array is showing as tree.I want to add /append dynamically child nodes while clicking on few of the nodes in this static tree.
Please help.
回答1:
If you set the children
property of a particular node to true
then the node is rendered as closed, and when the node is expanded then core.data.data
and core.data.url
functions are called (this is assuming you are using AJAX).
See the docs for using AJAX http://www.jstree.com/docs/json/
Alternatively you can supply a function for core.data
which is what is called to load the tree, and any nodes.
回答2:
If you read the jsTree API, you can make use of these below.
get_children_dom (obj)
draw_children(node)private
Learn how to fetch a single child node and draw it.
来源:https://stackoverflow.com/questions/29301155/jstree-append-child-node-dynamically