我使用Jstree 1.0RC3,并且没有让它工作来选择一个节点并让树打开以便此节点可见。 我的代码是这样的:jstree预选节点并打开所有需要的父节点
.jstree({
// List of active plugins
"plugins" : [
"themes","json_data","ui","crrm","dnd","search","types","hotkeys","contextmenu"
//"themes","json_data","ui","crrm","cookies","dnd","types","hotkeys"
],
"json_data" : {
"ajax" : {
"url" : $path + "/server.php",
"data" : function (n) {
return {
"operation" : "get_children",
"id" : n.attr ? n.attr("id").replace("node_","") : <?php echo($jstree_root); ?>
};
}
}
},
},
"core" : {
// just open those two nodes up
// as this is an AJAX enabled tree, both will be downloaded from the server
"initially_open" : [ <?php echo($jstree_root_node); ?> ]
与UI插件是空的。 php echo($ jstree_root_node)打开根目录下的第一个层级以获得更好的概述。有时我想传递一个应该选择的节点的ID。通过默认打开树,该节点并不总是可见的。我所看到的是,如果节点在第一层级中可见,那么它将被选中。如果它更深,它不会被选中。
我在论坛发现JSTREE调用之前用这一点,但它不工作:
.bind("reopen.jstree", function() {
$("#demo").jstree("select_node", "#node_1637");
$("#node_1637").parents(".jstree-closed").each(function() {
$("#demo").jstree("open_node", this, false, true);
});
})
任何想法在这一个?这似乎是正确的在我的鼻子前面,但我没有看到它....
gb5256
搜索是一个很好的方向,几乎没有太多的编码(只有在后台稍微改变)所有的用例最终确定 我仍然缺少的是打开完整路径时调用的异步事件。 –