get_next_dom(obj, true) for begginers

308 views
Skip to first unread message

denis mesic

unread,
May 12, 2014, 9:56:35 AM5/12/14
to jst...@googlegroups.com
Hi Ivan,

Great tool you have here.

I'm using it to display my database structure and i'm trying to get the "data-*"  value of next sibling,

$('#jstree').on("move_node.jstree", function (e, data) {
 
var nextNode = get_next_dom(data.node.id);
  alert
(nextNode.id);
});

I can access every property of moved object, but i need also properties of next node. After i move the node i need to get the data-sort from next sibling so i can update my database for ordering.
Just wandering where and how to call this function.
Thanks
Denis

Ivan Bozhanov

unread,
May 12, 2014, 11:42:48 AM5/12/14
to jst...@googlegroups.com
To get the next sibling use (inside the event handler):
data.instance.get_node(data.parent).children[data.position + 1]
And to get something you set as a data attribute use:
data.instance.get_node(data.instance.get_node(data.parent).children[data.position + 1]).data.someProperty

You should not rely on get_next_dom (you should have used data.instance.get_next_dom btw) because only visible nodes are rendered in the DOM.

Best regards,
Ivan

denis mesic

unread,
May 12, 2014, 2:15:56 PM5/12/14
to jst...@googlegroups.com
Thanks a lot man, its all easy now!!
Reply all
Reply to author
Forward
0 new messages