有添加后/前功能,以jtree

Have add after/before function to jstree

本文关键字:jtree 功能 添加      更新时间:2023-09-26

是否有一种方法,我可以有,add_before和add_after到jtree

例如:

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

documentation :

jtree使用事件来通知树中发生的任何更改。所有事件在jstree名称空间中的树容器上触发,并且是以触发它们的函数命名。

还有一个特殊事件- before. jtree。此事件启用您可以阻止一个操作的执行。

因此,您应该能够像这样在插入新节点之前和之后侦听事件:

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