tags:

views:

898

answers:

2

I wish JStree had more examples of peforming AJAX actions when deleting a node, etc. Like how does it transfer the ID of selected node and pass that as a parameter? Spent a few hours and can't figure this one out.

<li id="10" class="open"><a style="" class="clicked" href="#"><ins>&nbsp;</ins>fff</a> </li> 
<li id="1" class="open"><a href="#"><ins>&nbsp;</ins>111</a> </li> 
<li id="2" class="open"><a href="#"><ins>&nbsp;</ins>aaa</a> <ul> 
<li id="3" class="open"><a href="#"><ins>&nbsp;</ins>Wonderful</a> <ul> 
<li id="9" class="open last"><a href="#"><ins>&nbsp;</ins>bbb</a>
 </li> 
 </ul> 

So if I do something like a rename, how do I get the ID in the LI tag of selected node like the node_id?

$("#tree2").tree({
    callback : {
    onrename : function (NODE, TREE_OBJ) {
        alert(node_id); 
    }

} });

Any help appreciated!

+2  A: 

The plugin passes you the node involved; have you tried simply

alert($(NODE).attr('id'));

?

Pointy
yay! that works!! awesome!
Scott
Well I'm happy for you! Good luck. I've only played with jsTree a little bit but it looks pretty slick.
Pointy
I wish they would add some examples like what you just did. It would help so much. Common usage scenarios.
Scott
I have a similar problem but what if you created a new node and by default it has no id attribute. What will be the basis of my div storage if there is no ID? I can't use the node name itself because it can have duplicates.
marknt15
A: 

This helped me a lot, Thanks!!!

Its a wonderful blog, i always find my answers here. Thanks

Meenakshi