jstree drag and drop restrict node before and after root

drag-and-drop, javascript, jquery, jstree, tree

Solution

You are very close, you just need a else statement to return true

http://jsfiddle.net/blowsie/juyMR/59/

 "crrm" : {
        "move" : {
            "check_move" : function (data) {
               // alert(data.r.attr("id"));
                if(data.r.attr("id") == "999") {
                    return false;
                }
                else {
                    return true;
                }
            }
        }
    },

Problem

In my jstree I have a Root node which is the parent node of all. I have used dnd plugin. I want to allow drag and drop anywhere in the tree but only inside the root i.e. not before or after the Root. ``` - [Root] - Node 1 - Node 1.1 - Node 1.2 + Node 2 - Node 3 + Node 3.1 ``` After checking with forums I found that `drag_check` event is for foreign nodes only and not for any node within the tree. To validate for same tree node we need to use `crrm -> check_move` event. That is where I need help. I want to return false if the node is dropped before or after `[Root]`. Here is the fiddle to start - http://jsfiddle.net/juyMR/23/

Original source