开发者

Set node attributes on node in jstree

When I load the tree I load it using the following snippet:

{"data":"admin","state":"closed","metadata":{"id":"\/admin\/","type":"default"}

When I grab a referenced to a particular chosen node I use:

jQuery.data(data.rslt.obj[0], "jstree").id;

However, when I add a new node, i'm not sure how to set the id of the new node. I've seen some examples that say to use the开发者_Python百科 following:

var newnode = data.rslt.obj;
newnode.attr("id", new_node_id);

Where new_node_id is generated by me, but this doesn't seem to work. Can someone help?


I just use the provided method from the CRRM documentation:

$("#treeContainer").jstree("create", parentNode, "position", {attr: {id: your_generated_id ...}, data: "nodeTitle"} ,null, true);

Works like a charm for me.


If you are using json data to populate your tree, then you should supply it in the json string: see the docu

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜