Usually I can get the identifier of the tree nodes by default, but my problem is onCreate, then jsTree will add a new node, but it has no identifier. My question is: how to add an identifier to a newly created node tree?
What I'm going to do is add the HTML ID attribute to the newly created node tree, but how?
I need to get the identifier of all nodes, because it will serve as a reference for the corresponding div node storage.
HTML code:
<div class="demo" id="demo_1">
<ul>
<li id="phtml_1" class="file"><a href="#"><ins> </ins>Root node 1</a></li>
<li id="phtml_2" class="file"><a href="#"><ins> </ins>Root node 2</a></li>
</ul>
</div>
JS Code:
$("#demo_1").tree({
ui : {
theme_name : "apple"
},
callback : {
onrename : function (NODE, TREE_OBJ) {
alert(TREE_OBJ.get_text(NODE));
alert($(NODE).attr('id'));
}
}
});
Cheers, Mark
source
share