开发者

JSTree: Make node expand when single clicked instead of double click?

I can't figure this out for the life of me but I am trying to configure my JSTree to override the double click event so it is just single click event. Is this something added to the callback configuration? I am not sure how to do this, will I need to edit the JSTree source code? Documentation here: http://docs.planbleu.org/modules/webportal/jquery/jsTree.v.0.9.5/documentation/#configuration

I tried changing the "ondblclk" to "click" in开发者_如何学C the source code and then adding a "click" callback option to the config settings and it did nothing... I am probably doing it wrong though.


sending this into the tree creation function did the trick:

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

(where t is the reference to the tree)


I found the correct answer in an issue for the plugin on github. The above answers do NOT work. This absolutely works and is a comprehensive answer on how to call the plugin, and how to make it use single-click expand instead of double-click.

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

Here is a link to where the author mentions the solution, in case you need it.


$("#tree").bind("select_node.jstree", function (e, data) {
 $("#tree").jstree("toggle_node", data.rslt.obj);
 $("#tree").jstree("deselect_node", data.rslt.obj);
});

This might get you started in the right direction. You'll probably need to filter out which ones to expand or not depending on meta data.


  $fullIndex.on('select_node.jstree', function(e, data){
    data.instance.toggle_node(data.selected);
  })
  .jstree()


 $("#your_id_where_Tree").on('select_node.jstree', function(e, data){
       data.instance.toggle_node(data.selected);
 });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜