jsTree » Demos

# Moving nodes demo

As you may have noticed, you can drag nodes around. You can influence the ability to drop a node somewhere using the type max_children setting, type max_depth setting and type valid_children setting. If you want to disable dragging a node type use the type draggable setting (you can event use it on the default node type). When moving the beforemove, onmove, oncopy, check_move and ondrop callbacks are triggered. Also if you assigned a function to them the global tree.drag_start, tree.drag, tree.drag_end are fired. Ondrop is only fired when dropping foreign items on the tree - for more on that - check the tree.drop_mode function.

If you want to copy when dragging without holding control or disable copying - read about the drag_copy setting.

For dragging items from one tree to another - check the multitree setting.

To move nodes programatically use the copy, cut & paste functions.

- Root node 1
  - Child node 1
  - Child node 2
  - Some other child node with longer text
- Root node 2

Log: