How to create a new ID for the new added node?
- by marknt15
Hi,
I can normally get the ID of the default tree nodes but my problem is onCreate then jsTree will add a new node but it doesn't have an ID. My question is how can I add an ID to the newly created tree node?
What I'm thinking to do is adding the ID HTML attribute to the newly created tree node but how?
I need to get the ID of all of the nodes because it will serve as a reference for the node's respective div 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