krische
krische

Reputation: 1010

jstree not moving a node after dropping

I'm trying to setup drag n drop inside a jstree. I want it so that the nodes can only be moved, not reordered.

My check_move function looks like this:

"crrm" : {
    "move" : {
        "check_move" : function (m) {
            if(m.p == "inside")
                return true;
            else
                return false;
        }
    }
},

However this doesn't appear to be working. The tree never moves the nodes, and the move_node event is never fired.

I have a JSFiddle setup to demonstrate what I mean: http://jsfiddle.net/PJcHm/1/ Try dragging and dropping to move Node 2 inside of Node 1.

Upvotes: 1

Views: 739

Answers (1)

krische
krische

Reputation: 1010

I figured it out after a little debugging. It looks like after releasing to drop the node inside another node, the check_move function is called one more time, with the level variable p equal to "last". So I was returning false for that. The proper code is:

"crrm" : {
    "move" : {
        "check_move" : function (m) {
            if(m.p == "inside" || m.p == "last")
                return true;
            else
                return false;
        }
    }
},

Upvotes: 1

Related Questions