我正在嘗試使用JSON生成的jsTree來導航目錄結構。目前,我綁定了一個select_node事件來獲取選定節點的路徑作爲字符串,然後將location.hash
設置爲該路徑。這部分實際上工作正常。我的問題是,在我的select_node事件完成之後,立即從url中完全刪除哈希,這顯然會中斷瀏覽器歷史並將用戶發送回「索引」頁面。這是我目前的代碼。我如何防止這種情況發生?jsTree從URL中刪除哈希
$('#projects').jstree({
core: {
animation: 0
},
plugins: ["themes", "json_data", "ui"],
themes: {
theme: "gm",
dots: false
},
json_data: {
ajax: {
url: '/json/projects',
},
progressive_render: true
}
}).bind('select_node.jstree', function(e, data){
var path = '#/' + $(this).jstree('get_path', data.rslt.obj, false).join('/')
window.location.hash = path
})
我也想知道這一點。明天我會有同樣的問題:) –