6

I have a tree like this:

ROOT
|---n1-1
      |---n2-1
            |---n3-1
      |---n2-2
            |---n3-2
|---n1-2
      |---n2-3
      |---n2-4
            |---n3-3
            |---n3-4

Is it possible to configure jsTree so that only n3-x nodes are draggable and they can only be dropped as n2-x node's children?

codependent
  • 23,193
  • 31
  • 166
  • 308

1 Answers1

1

On jsTree's documentation, it points out a configuration option for the drag and drop plugin called $.jstree.defaults.dnd.is_draggable:

A function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) and the event that started the drag - return false to prevent dragging

You should be able to write a function which will check if it is an n3-x node.

I unfortunately don't see anything for specifying where it can be dropped within the documentation, but it looks like elsewhere on StackOverflow someone has solved this: dnd, how to restrict dropping to certain node types?

Community
  • 1
  • 1
Adam
  • 2,446
  • 1
  • 13
  • 16