JsTree v3.0 拖放插件.放置时参考目标节点

2022-01-11 00:00:00 drag-and-drop javascript jstree

我使用 jsTree 库的拖放插件(版本 3.0)使用以下代码,我可以绑定到拖放操作的末尾,但我看不到获取对目标节点(我要放置的节点)的引用的方法.

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?
});

推荐答案

另一种解决方案是在jstree对象上使用get_node()函数.

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;
});

您可以让所有父母:

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

相关文章