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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With