我正在尝试使用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
})
我也想知道这一点。明天我会有同样的问题:) –