Only open the root node on initializing a tree.

1,686 views
Skip to first unread message

Thomas Mang

unread,
Jul 10, 2014, 8:48:35 AM7/10/14
to jst...@googlegroups.com
Hi, 

i am getting a plain HTML List in tree structure, that is generated automatically, and i don't know some ids, which are used there for UL or LI tags - i only know, that the div tag has an ID, that starts with jstree, so i am initializing a js tree with the following code: 

$(function() {
$('div[id^="jstree"]')
.jstree({
"plugins" : [ "checkbox" ],
"core" : {
"multiple" : true,
"themes" : {
"dots" : false,
"icons" : false,
"stripes" : false
},
"animation" : 0
}
})
}

This is working fine.
No id like to "open" the root node, and only the root node - not all nodes.

Thats the main problem.
A "smaller" problem is, that i like to "hide" the root node too, but this is not so important. 

Could you give me a hint, how to open just all childs of the root node during or after initialization of this tree?

Thanks in advance,
Thomas

Ivan Bozhanov

unread,
Jul 10, 2014, 2:41:13 PM7/10/14
to jst...@googlegroups.com
Read here: http://www.jstree.com/docs/html/
Look for the: Setting initial state with classes section

Basically - just add the jstree-open class to the LI node you'd like opened.

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages