This is a migrated thread and some comments may be shown as answers.

Double-Click on treeview node not working after drag/drop

2 Answers 98 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 19 Jun 2015, 04:57 PM

I'm handling double-clicks on a treeview node like this:

 

$("#treeview [role=treeitem] span").on("dblclick", function(e){
      var tree = $("#treeview").data("kendoTreeView");
      var item = tree.dataItem($(e.target).closest("li"));
    });

It works great until I enable dragAndDrop on the tree.  If a node is dragged/dropped to another location, double-clicking on it no longer fires the "dblclick" event on the treeview.

 You can test this here:

http://jsbin.com/fubajoyexe/edit?html,output

Just add "dragAndDrop: true," to the treeview configuration, then drag a node to another location.  Double-click on that node and it no longer works.  Do you know of any workarounds?

2 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 19 Jun 2015, 05:26 PM

It works find if I redefine the onclick section like this:

 

$("#treeview").on("dblclick", function(e){
      var tree = $("#treeview").data("kendoTreeView");
      var item = tree.dataItem($(e.target).closest("li"));
    });

0
Accepted
Alex Gyoshev
Telerik team
answered on 23 Jun 2015, 06:19 AM

Hello Scott,

Yes, in the first case you define an event handler for all existing spans, and when one is newly added, it won't have the event handler attached to it. The second snippet attaches the event handler to the root element and determines which node has been clicked, which makes it work for new elements, too.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeView
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or