我无法想象我的生活,但我正在尝试配置我的JSTree来覆盖双击事件,因此它只是单击事件.这是否会添加到回调配置中?我不知道该怎么做,我需要编辑JSTree源代码吗?这里的文档:http://docs.planbleu.org/modules/webportal/jquery/jsTree.v.0.9.5/documentation/#configuration
我尝试在源代码中将"ondblclk"更改为"click",然后在配置设置中添加"click"回调选项,它没有做任何事情......我可能做错了.
将其发送到树创建函数中就可以了:
onselect: function(n, t) {
t.toggle_branch(n);
},
Run Code Online (Sandbox Code Playgroud)
(其中t是对树的引用)
我在 github 上的插件问题中找到了正确答案。上面的答案不起作用。这绝对有效,并且是关于如何调用插件以及如何使其使用单击展开而不是双击的全面答案。
$('#jstree')
.on('click', '.jstree-anchor', function (e) {
$(this).jstree(true).toggle_node(e.target);
})
.jstree()
Run Code Online (Sandbox Code Playgroud)
这是作者提到解决方案的链接,以防您需要。
$("#tree").bind("select_node.jstree", function (e, data) {
$("#tree").jstree("toggle_node", data.rslt.obj);
$("#tree").jstree("deselect_node", data.rslt.obj);
});
Run Code Online (Sandbox Code Playgroud)
这可能会使您朝正确的方向开始。您可能需要根据元数据筛选出要扩展或不扩展的内容。