JsTree v3.0 drag and drop plugin. Reference target node upon dropping

eagor picture eagor · Apr 6, 2014 · Viewed 10.1k times · Source

I use drag and drop plugin of jsTree library (ver. 3.0) With the following code I can bind to the end of drag'n'drop action, but I can not see a way to get the reference to the target node (the node I'm dropping on).

$(document).on('dnd_stop.vakata', function(e, data) {
   // how to get target_node here?
});

Answer

stacked picture stacked · Feb 27, 2015

Another solution is to use the get_node() function on the jstree object.

$(document).on('dnd_stop.vakata', function (e, data) {
    ref = $('#jstree').jstree(true);
    parents = ref.get_node(data.element).parent;
});

You can get all parents with:

    all_parents = ref.get_node(data.element).parents;