How can I attach custom behaviour to a double click in jsTree? How can I attach custom behaviour to a double click in jsTree? jquery jquery

How can I attach custom behaviour to a double click in jsTree?


It turns out I can do this:

jstree.bind("dblclick.jstree", function (event) {   var node = $(event.target).closest("li");   var data = node.data("jstree");   // Do my action});

node contains the li that was clicked and data contains the metadata with my info in it.


'dblclick.jstree' doesn't exist in last version jsTree 1.0.

DoubleClick for node:

$("#yourtree").delegate("a","dblclick", function(e) {  var idn = $(this).parent().attr("id").split("_")[1];  alert(idn); //return NodeID    });

Insert this if you want just dblclicked node

if (this.className.indexOf('icon') == -1) {  /* is the node clicked a leaf? */ }


It's a bit different to get the data out for me, but otherwise GiddyUpHorsey's answer was spot-on. Here is the code again:

        jstree.bind("dblclick.jstree", function (e, data) {            var node = $(e.target).closest("li");            var id = node[0].id; //id of the selected node        });