Eduardo Sousa
Eduardo Sousa

Reputation: 1075

JSTree Drag n Drop Checking Callback

I'm using JSTree and it has shown to be an awesome tool. Using the Drag and Drop plugin I came across this:

When I drag a file to a folder with valid_children that does not allow files it does not show the red cross, but also does not allow to drop (as valid_children expected behavior). For a better user expecience I need to show the cross when the parent node's valid_children does not contain the node being dragged's type. Here is an example of what I am looking for:

Example of what I am looking for.

Any ideas?

Upvotes: 1

Views: 648

Answers (1)

Eduardo Sousa
Eduardo Sousa

Reputation: 1075

Found the solution and it differs a little from what I've found in StackOverflow

  • explicitly define your valid_childrens on "types" configuraton.
  • add parameters on check_callback to function(operation, node, node_parent, node_position, more)
  • add to check_callback:

switch (operation) { case 'move_node': return ($.inArray(node.type, this.get_rules(more.ref).valid_children) != -1); default: return true; }

Upvotes: 1

Related Questions