jstree: create new node not working
$('#create-blank-node').click(function () {
$('#treepanel').jstree("create", $("#parent_node"), "first", "new node");
});
"treepane开发者_如何学Gol" is a div id which is a tree. This function is not working.
I fixed the issue, it should be 'create_node' instead of 'create': like this
$('#create-blank-node').click(function () {
$('#treepanel').jstree("create_node", $("#parent_node"), "first", {attr : {id: newNodeId}, data: newPartName});
});
It is worked correctly. Thanks for reply
add a new node
$("#categories_jstree").jstree('create_node', '#', {'id' : '1944', 'text' : 'nosde1'}, 'last');
where # is a parent node id (empty_now)
add a nested node for node1
$("#categories_jstree").jstree('create_node', '#1944', {'id' : '1945', 'text' : 'subnode1_1'});
the #1944 - parent node id
Could you provide your tree structure? Looking at your snippet, I'm assuming that "parent_node" is a valid node within the tree (already exists) and doesn't have any rules (types plugin) that would limit it from receiving a new child node. Are you binding to any functions in your tree and doing custom work?
What happens if you just do this?:
$('#treepanel').jstree("create");
精彩评论