How to listen to double click on jstree?

How do I write a listener for a double-click event on a jstree object? (For example, I would like to double-click on the node tree and paste its href binding value into the input field on the form somewhere.)

+6
source share
2 answers

I used something like this back a year ago, I don't know if there are any changes in the current version of jstree:

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

node: Whether contains which is clicked.

data: Contains metadata.

+8
source

The Nirmal solution works if you click anywhere in the jstree div. I wanted to enable double-click only on the nodes themselves, and not, for example, in the space on the right. a change in solution activated this a bit:

 $('#jstree-div a').live('dblclick',function (e) { var node = $(e.target).closest("li"); var type = node.attr('rel'); var item = node[0].id; // do stuff... }); 

I don’t know why the attributes 'rel' and 'id' are in different places in the resulting node, but it works;)

+4
source

Source: https://habr.com/ru/post/887593/


All Articles