JSTree: Make node expand when pressed once instead of double-clicking?

I can't figure it out for life, but I'm trying to configure JSTree to override the double-click event, so this is just a one-click event. Is this something added to the callback configuration? I'm 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 the source code and then adding the “click” callback option to the configuration settings and it did nothing ... Maybe I'm wrong.

+8
source share
4 answers

sending this function to the tree creation function did the trick:

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

(where t is a link to a tree)

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

This will help you get started in the right direction. You will probably need to filter out which ones will expand or not, depending on the metadata.

+6
source

I found the correct answer in the problem for the github plugin. The above answers do NOT work. This absolutely works and is an exhaustive answer on how to call the plugin, and how to make it with one click, instead of double-clicking.

    $('#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 , if necessary.

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

All Articles