I am trying to define the new parent id for a node after a dragdrop event.
This function works fine assuming you drag a node to any level other than root
dragDrop: function(node, data) {
/** This function MUST be defined to enable dropping of items on
* the tree.
*/
data.otherNode.moveTo(node, data.hitMode);
// Set Parent ID with id of parent
data.otherNode.data.parent_id = node.data.id;
}
However when dragging a node to the root it takes on an id from somewhere else (I haven't figured out the pattern yet).
I've been monitoring the fancytree node.key (which shows the key of the parent node) and it always outputs key_2
and never root_1
which is the value of root when I output the tree using the tree.toDict(true); function.
What is the proper way to find out if a node has been dragged to the root?