8

我一生都无法弄清楚这一点,但我正在尝试配置我的 JSTree 以覆盖双击事件,因此它只是单击事件。这是添加到回调配置中的东西吗?我不知道该怎么做,我需要编辑 JSTree 源代码吗?此处的文档:http: //docs.planbleu.org/modules/webportal/jquery/jsTree.v.0.9.5/documentation/#configuration

我尝试在源代码中将“ondblclk”更改为“click”,然后在配置设置中添加“click”回调选项,但它什么也没做……不过我可能做错了。

4

5 回答 5

7

将其发送到树创建函数中就可以了:

   onselect: function(n, t) {
         t.toggle_branch(n);
    },

(其中 t 是对树的引用)

于 2011-01-19T16:33:13.290 回答
6
$("#tree").bind("select_node.jstree", function (e, data) {
 $("#tree").jstree("toggle_node", data.rslt.obj);
 $("#tree").jstree("deselect_node", data.rslt.obj);
});

这可能会让你朝着正确的方向开始。您可能需要根据元数据过滤掉哪些要扩展或不扩展。

于 2011-01-13T01:03:50.047 回答
4

我在 github 上的插件问题中找到了正确答案。上述答案不起作用。这绝对有效,并且是关于如何调用插件以及如何使其使用单击展开而不是双击的全面答案。

    $('#jstree')
        .on('click', '.jstree-anchor', function (e) {
            $(this).jstree(true).toggle_node(e.target);
        })
        .jstree()

这是作者提到解决方案的链接,以备不时之需。

于 2016-08-10T13:09:20.607 回答
0
  $fullIndex.on('select_node.jstree', function(e, data){
    data.instance.toggle_node(data.selected);
  })
  .jstree()
于 2019-07-04T10:05:16.147 回答
0
 $("#your_id_where_Tree").on('select_node.jstree', function(e, data){
       data.instance.toggle_node(data.selected);
 });
于 2019-12-16T20:14:48.287 回答