js 树 create_child,创建兄弟节点而不是 child

js tree create_child, creates sibling not child

我使用 jstree 上下文菜单创建新的 child 节点。 当我这样做时,jstree 创建了我单击的节点的同级节点,我需要它来创建该节点的 child 节点。

这是我的代码:

ref.create_node(sel, data, "after");

sel = parent id

数据=child节点

首先,我必须获得父项的最后一个子项 ID:

var lastChild = $("#"+sel).find("li:last-child").attr("id");

然后将其用作我要创建的子节点的父节点。

ref.create_node(lastChild, {"type":"tag", "id":data.id}, "after");

我想知道是否有更直接的方法来做到这一点。