gpt4 book ai didi

javascript - 向 jstree 添加 after/before 功能

转载 作者:行者123 更新时间:2023-11-28 02:13:30 24 4
gpt4 key购买 nike

有没有办法可以将 、 add_before 和 add_after 添加到 jstree

例如:

.bind("add_after.jstree", function (node,data){
#perform some function
})

最佳答案

来自documentation :

jsTree uses events to notify of any changes happening in the tree. All events fire on the tree container in the jstree namespace and are named after the function that triggered them.

There is also one special event - before.jstree. This events enables you to prevent an operation from executing.

因此,您应该能够在插入新节点之前和之后监听事件,如下所示:

$(function () {
$("#treeId").bind("before.jstree", function (e, data) {
if(data.func === "create_node") {
// This block will execute before inserting a new node
}
});

$("#treeId").bind("create_node.jstree", function (e, data) {
// This block will execute after inserting a new node
});
});

关于javascript - 向 jstree 添加 after/before 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16736020/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com