0

I am using the jstree dnd plugin. To set the nodes where dropping is allowed I am using the "types" plugin and the valid_children property. This works even in between two different trees.

However I would like to prevent to drop a node on a different tree than the original one and therefore not to show the green arrow when the mouse is on a different tree.

Any solution for that ?

DeFré
  • 1
  • 1

1 Answers1

0

Actually I found a very simple solution by adding a plugin to jstree :

$.jstree.plugins.myplugin = function (options, parent) {

    // Blocks DND on an other tree than the original one
    this.check = function (chk, obj, par, pos, more) {
        if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
        if (more && more.dnd && more.is_multi) {return false}
        return true;
        };
    };

The 'check' function is already used by the 'DND' and 'types' plugin to define which nodes are a potential area for drop. This drives also the display of the green check or red cross. The more.is_multi allows to detect weather the target is in a different tree instance than the original instance.

Then do not forget to add this plugin to you list of plugins when creating a new jstree instance.

DeFré
  • 1
  • 1