我设置selected: true
$('#tree3').jstree({ 'core' : {
'data' : [
{ "id" : "ajson2", "parent" : "#", "text" : "Root node" , state : {opened : false}},
{ "id" : "ajson5", "parent" : "ajson2", "text" : "Child 3" , state : {opened : false, selected: true}, icon: false},
{ "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" , state : {opened : false, selected: true}, icon: false}
]
},
"checkbox" : {
"keep_selected_style" : false
},
"plugins" : [ "checkbox" ]
});
为什么打开了我的节点?
如果我尝试selected: false
,我会关闭节点,但不会检查。
jsTree - v3.2.1及更早版
答案 0 :(得分:1)
默认情况下,所有节点都未打开,但在启动时显示。使用expand_selected_onload如下所示,您应该能够以未打开的状态加载树:
$('#tree3').jstree({ 'core' : {
'data' : [
{ "id" : "ajson2", "parent" : "#", "text" : "Root node" , state : {opened : false}},
{ "id" : "ajson5", "parent" : "ajson2", "text" : "Child 3" , state : {opened : false, selected: true}, icon: false},
{ "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" , state : {opened : false, selected: true}, icon: false}
],
expand_selected_onload : false
},
"checkbox" : {
"keep_selected_style" : false
},
"plugins" : [ "checkbox" ]
});