PDA

View Full Version : Tree: nodedrop event



mcahill81
19 Mar 2010, 6:39 AM
This is probably an easy question and the answer's probably staring me right in the face.. but.. On a nodedrop, how do I glean the previous (source?) parentNode of the node that's being dropped from the dropEvent object.

Animal
19 Mar 2010, 7:32 AM
Have you tried its parentNode property?

Animal
19 Mar 2010, 7:33 AM
No, that will be its new parent. In the beforenodedrop handler, it will still have its old parent.

mcahill81
19 Mar 2010, 7:34 AM
dropEvent.dropNode.parentNode is returning the NEW (target) parent

pashcan
23 Mar 2010, 2:35 PM
Sorry mcahill81, but Animal is right on this one. If you output a dropEvent.dropNode.parentNode within beforeNodeDrop handler and the same within nodeDrop handler, you will get different parent nodes (obviously only if you drag'n'drop to a different parent).

I actually tried it myself because I am performing some validation in these handlers and needed a way to restore dropNode's original location when validation fails.