Question

can somebody please tell how to use this solution to solve my problem. I too want to restrict drag/drop for a node whose id has text "not" in it.

jsTree drag and drop restrict folders by class

here is fiddle http://jsfiddle.net/fuu94/112/

"crrm" : {
    "move" : {
        "default_position" : "first",
        "check_move" : function (m) {  
            return (m.o.hasClass("locked") || m.r.hasClass("locked")) ? false : true;  
        }
     }
}
Was it helpful?

Solution

Ok, I looked into it and I think it is working. It seems that crrm plugin is no more available for jstree AND you can achieve your result using only dnd plugin using following self-explanatory code

$('#tree').jstree({
    core: {
       check_callback: function (op, node, node_parent) {
          return op == 'move_node' ? node_parent.id.indexOf('not') === -1 : true;
       }
    },
    dnd: {
       is_draggable: function (x) {
          return x[0].id.indexOf('not') === -1;
       }
    },
    "plugins": ["dnd"]
 });

This code prevents moving of said nodes and also prevents moving of other nodes into them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top