Closed GoogleCodeExporter closed 9 years ago
Hi. I solved my problem with this code (as part of the onDrop event) but it
seems like a bit of a cluge. Is there a better way?
onDrop: function(node, sourceNode, hitMode, ui, draggable) {
/**This function MUST be defined to enable dropping of items on the tree.
* sourceNode may be null, if it is a non-Dynatree droppable.
*/
// ...
// Find the dropped node's parent and get the parent's key
//
if (hitMode == "over") {
// The dropped node was dropped on this node so this node IS the parent
var droppedNodeParentKey = node.data.key;
} else {
// The dropped node was dropped either before or after the node.
// The dropped node is therefore a sibling of node so:
// the dropped node's parent is node's parent
var droppedNodeParent = node.getParent(); // get the sibling's parent
var droppedNodeParentKey = droppedNodeParent.data.key;
}
alert("Parent key: " + droppedNodeParentKey);
}
Original comment by leschamb...@gmail.com
on 17 Jul 2013 at 2:59
To clarify: This solution worked for me because I actually needed the parent
key to populate a relational database. This method would not get the dropped
node key if the node was dropped with hit mode "over" on a node that had
children. You wouldn't know which of the children had just been dropped. So I
guess the problem still remains.
Original comment by leschamb...@gmail.com
on 17 Jul 2013 at 3:07
Just curious: if the keys are important to you, why don't you assign them
yourself instead of letting dynatree generate arbitrary ones?
Original comment by moo...@wwwendt.de
on 20 Jul 2013 at 3:05
Original comment by moo...@wwwendt.de
on 8 Sep 2013 at 6:47
Original issue reported on code.google.com by
leschamb...@gmail.com
on 17 Jul 2013 at 2:10