问题
I am facing difficulty in deleting child nodes of a selected node.
$(function () {
$("#tree").jstree({
"json_data" : {
"data" : [
{
data : "/",
attr : { "id" : "root"},
state : "closed",
"children" : [ { "data" : "child1",
"attr" : { "id" : "child1.id" },
"children" : [ ] }
]
},
]
},
"plugins" : [ "themes", "json_data", "crrm", "ui" ]
})
I am using $("#tree").jstree("remove", data.rslt.obj); to remove the child nodes below the node itself but it also deletes the node selected. How can I delete the just child nodes of a selected node and not the selected node ?
回答1:
As @Redtopia correctly pointed out, jsTree does not have the cleanest API.
Unfortunately, I believe that the solution will have to be something like:
$("#tree").jstree("remove",data.rslt.obj.find('li'));
来源:https://stackoverflow.com/questions/18861654/how-to-remove-child-nodes-of-selected-node-in-jstree