user412264
user412264

Reputation: 221

jsTree drag and drop restrict folders by class

How can you lock the drag function on a folder by class name class="locked"? And on the same time lock other folders to be draged into this folder class="locked".

I want a setup where I have both drag and drop, and contextmenu. If the node has the class name "locked" I just want to disable editing for both contextmenu and possibility to drag into this folder or drag this folder to new location.

Tnx

Upvotes: 3

Views: 1897

Answers (1)

user412264
user412264

Reputation: 221

Found a way by using the CRRM plugin combined with core documentation for .get_move().

".o" is the node being moved, and ".r" is the reference node in the move.

http://www.jstree.com/documentation/core

http://www.jstree.com/documentation/crrm

Here is my code:

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

Upvotes: 4

Related Questions