我使用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
搜索是一個很好的方向,幾乎沒有太多的編碼(只有在後臺稍微改變)所有的用例最終確定 我仍然缺少的是打開完整路徑時調用的異步事件。 –