简体   繁体   中英

How to get the node and Source node jQuery dynatree?

I am trying drag and drop option with jquery dynatree. Here upon drop of a node on another node I have to perform some db operation so I can call a function which makes ajax call. The problem I am facing is how to get node and source node when I write a function for onDrop option. Here is my dnd of dynatree,

 dnd: {
      preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
      onDragStart: function(node) {
        return true;
      },
      onDragEnter: function(node, sourceNode) {

        if(node.parent !== sourceNode.parent)
          return true;
        return ["before", "after"];
      },
      onDrop: function(node, sourceNode, hitMode, ui, draggable) {
         alert("moved Node: "+node+"  SourceNode:"+sourceNode);
        sourceNode.move(node, hitMode);
      }
    }

The alert in onDrop displays like this ,

Moved Node: DynatreeNode :'default' SourceNode: DynatreeNode <123>: '123'

Here I want just values default and 123 . How can I get that ?

to get the key do:

var value = sourceNode.data.key;

basically if you want access to the node options, just use node.data.optionyouwant

see: Node Options

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM