Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jstree

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.

like image 924
T.Kaukoranta Avatar asked May 24 '11 12:05

T.Kaukoranta


1 Answers

I found the answer to my own question pretty soon after asking about it (typical).

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

I would delete this post, but I think this could be a pretty common problem. If someone thinks otherwise, feel free to delete.

like image 169
T.Kaukoranta Avatar answered Sep 17 '22 22:09

T.Kaukoranta