我正在使用JStree處理我的第一個應用程序,並且我已經做了幾乎所有我需要的作爲導航樹。我有javascript代碼工作,它使用knockoutjs爲頁面動態構建html列表結構(這裏有點矯枉過正,但我在頁面的其他地方使用了knockout)。我連接到HTML JStree後,我的DOM看起來喜歡 -與JStree的「beginning_open」選項的問題
<div id="menuTreeList" data-bind="template: "treeMenuTemplate"" class="navtree
jstree jstree-0 jstree-focused jstree-default">
<ul class="jstree-no-dots jstree-no-icons">
<li id="menu_1" class="jstree-leaf"><ins class="jstree-icon"> </ins><span>
<a href="#" class=""><ins class="jstree-icon"> </ins>CARES Home</a></span>
</li>
<li id="menu_2" class="jstree-closed"><ins class="jstree-icon"> </ins><a href="#">
<ins class="jstree-icon"> </ins>Case Management</a>
<ul>
<li id="menu_3" class="jstree-leaf"><ins class="jstree-icon"> </ins><span class="navtree-spanDefault">
<a href="#"><ins class="jstree-icon"> </ins>Search</a></span> </li>
<li id="menu_4" class="jstree-leaf"><ins class="jstree-icon"> </ins><span class="navtree-spanDefault">
<a href="#"><ins class="jstree-icon"> </ins>Participant Summary</a></span>
</li>
<li id="menu_5" class="jstree-leaf"><ins class="jstree-icon"> </ins><span class="navtree-spanDefault">
<a href="#"><ins class="jstree-icon"> </ins>Transfer WP Office</a></span>
</li>
<li id="menu_6" class="jstree-last jstree-leaf"><ins class="jstree-icon"> </ins><span
class="navtree-selected">Update Individual Address</span> </li>
</ul>
</li>
<li id="menu_7" class="jstree-last jstree-leaf"><ins class="jstree-icon"> </ins><a
href="#"><ins class="jstree-icon"> </ins>Tools</a></li>
</ul> </div>
我的JavaScript調用JStree是
$(document).ready(function() {
$("#menuTreeList").jstree({
"themes": {
"theme": "default",
"dots": false,
"icons": false
},
"plugins": ["themes", "html_data"],
"core": {
"animation": 0,
"open_parents": true,
"initially_open": ["menu_5"]
}
});
})
產生的菜單看起來像
我的問題是,我想菜單最初將所有節點關閉,然後僅打開表示當前頁面「已選擇」的節點,並打開父節點。當我嘗試將JStree「initial_open」設置爲「menu_5」或「menu_6」時,菜單最初顯示爲關閉。
長期來看,這將是一個非常複雜的多層次結構。所以用戶正在尋找這種類型的功能。建議?