0
当我的复选框jstree加载完成后,我希望预先打开最后打开的节点(而不是select_node
)。 open_node
函数似乎只适用于最顶层的父级别节点。我甚至尝试遍历节点并调用open_node
,它仍然无法工作。我有以下几种:jstree open_node不能在子节点上工作
// Create instance for checkbox jstree.
$(function() {
$('#myTree').jstree({
"core": {
"themes": {
'name': 'default',
"variant": "small",
"icons": false
},
},
"checkbox": {
"keep_selected_style": false,
"three_state": false,
},
"plugins": ["checkbox"]
});
});
$("#myTree").bind('ready.jstree', function (event, data) {
var $tree = $(this);
$($tree.jstree().get_json($tree, {
"flat": true
})).each(function (index, value) {
// lastOpenedNode.value contains the id of the last opened node
if (nodeWasLastOpened(this.id) == true)
// ONLY OPENS TOP MOST PARENT NODES
$("#myTree").jstree().open_node(this.id);
})
});
请帮忙。
谢谢,我应该有措辞我的问题更好(由上述编辑)。我其实希望打开多个节点。这很好,但只能使用一次。 – usr4896260
我更新了答案,检查它是否适用于您 –
我发现了我的问题。我最初将节点id存储为字符串,然后将其传递给'open_node'函数。一旦我将它转换为“int”,该功能就可以完美工作。谢谢。 – usr4896260