我是jQuery和jstree的新手。请更正我的代码。从其文档来看,没有任何解决方案对我有用。我想选择一个父节点并为另一棵树创建完整的节点(父节点和子节点)。为此,我创建了以下代码:
// Moving nodes on click event
$(MoveButton).on('click', function() {
var parent = $(TreeContainer).jstree("get_selected", true); // to get selected parent node
var childrens = $(TreeContainer).jstree("get_childrens_dom", true); // to get all the children of the parent
var newNode = { text: $(TreeContainer).jstree("get_selected", true)[0].text }; //to get text of selected parent node
for(let i = 0; i < childrens.length; i++) {
$(NextTree).jstree(true).create_node(parent, newNode); // creating the selected node in next tree
parent = $(TreeContainer).jstree("get_next_dom", true); // to get the next node of the parent
newNode = { text: $(TreeContainer).jstree("get_next_dom", true)[0].text } ; // to get the text of next node of parent
}
}