Jstree - Stop node from being move outside it's parent

555 views Asked by At

I have a requirement where I need to restrict my jstree node not to move outside its parent. It can freely move inside within its parent.

This is the code I am trying:

$('#divUC').jstree({
    'core': {
        multiple: false,
        'check_callback': function (o, n, p, i, m) {
           if (o == "move_node" && n.type == "view") {
           }

Here shortcuts indicates:

  • o = operation,
  • n = node,
  • p = node_parent,
  • i = node_position,
  • m = more
1

There are 1 answers

0
Sudharshan Nair On

You can check in callback for this.

if(operation =='move_node'){
 if (this.get_node(node).parent === this.get_node(node_parent).id) { 
     return true; 
  } else { 
     return false;
  }
 }