jstree

.bind("move_node.jstree",.. -> data.rslt.obj undefined. How to get node data?


I have a custom functionality for check_move:

crrm : {
        move : {
            "check_move" : function (m) {

                var p = this._get_parent(m.o);
                if(!p) 
                    return false;
                if(m.cr===-1)
                    return false;
                return true;        
                }

        }   
    },

This seems to work as intended. I then try to bind to the "move_node" event to update my database:

.bind("move_node.jstree",function(event,data){
    if(data.rslt.obj.attr("id")==""){
         /* I omitted this snippet from this paste - it's really long and it basically does the same thing as below, just gets the node's id in a more complicated way*/
    } else { 
        controller.moveNode(data.rslt.obj.attr("id"),data.inst._get_parent(this).attr("id"),data.rslt.obj.attr("rel"));
    }   
})

This results in an error. data.rslt.obj is undefined. I'm truly at loss at what to do, I've binded to multiple events before and this is how I've done it.

How can I get node attributes etc after the move_node event, if data.rslt.obj doesn't work?

Oh, the controller.moveNode() is one of my own functions, so don't just copy-paste if you're trying to learn jstree.


Solution

  • One must use data.rslt.o.attr("id") instead of -.obj.- An odd inconsistency if you ask me.