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

3 posts, 1 answers
  1. Scott
    Scott avatar
    19 posts
    Member since:
    Mar 2011

    Posted 19 Jun 2015 Link to this post

    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. Scott
    Scott avatar
    19 posts
    Member since:
    Mar 2011

    Posted 19 Jun 2015 in reply to Scott Link to this post

    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"));
        });

  3. Kendo UI is VS 2017 Ready
  4. Answer
    Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 23 Jun 2015 Link to this post

    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!
     
Back to Top