WestCoast_BC
asked on
How to open all child nodes using jsTree
I am using jsTree to create a tree. I would like to have all of the child nodes automatically open and expand when a parent node is selected. Can anyone give me an example of how I can do this?
I am able to bind open_node to my tree but I haven't figured out how to get the ID of the selected node.
Thank you for your help
I am able to bind open_node to my tree but I haven't figured out how to get the ID of the selected node.
$("#my_tree").bind("open_node.jstree", function (e, data) {
// how do I get the id of the selected node?
$.jstree._reference("#my_tree").open_all('#Selected_id');
});
Thank you for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The code that I submitted in my last comment solved my problem
ASKER
My code that I submitted solved my problem
I think I have found best solution inspired from the accepted one:
To close all childrens: (tested)
To open all childrens (not tested yet)
To close all childrens: (tested)
$("#my_tree").bind("close_node.jstree", function (e, data) {
data.inst.close_all(data.rslt.obj);
return false;
})
To open all childrens (not tested yet)
$("#my_tree").bind("close_node.jstree", function (e, data) {
data.inst.close_all(data.rslt.obj);
return false;
})
Open in new window