如何将操作绑定到“创建/删除新节点” DynaTree 中的事件?

发布于 2024-12-31 23:43:04 字数 158 浏览 5 评论 0原文

DynaTree 入门。我想将一些代码绑定到“添加新节点”的事件。 onCreate 选项似乎在第一次渲染节点时被触发。是的,这包括创建节点的时间,但也包括加载和渲染树的时间,以及第一次展开折叠子树的时间。所以看起来不太合适。同样的问题也适用于删除节点。这些事件在哪里?

谢谢, 马可.

Getting started with DynaTree. I'd like to bind some code to the event which is "adding a new node". The onCreate option seems to be fired when a node is rendered for the first time. Yes, this includes when a node is created, but it also includes when the tree is loaded and rendered, and when a collapsed subtree is expanded for the first time. So it doesn't seem appropriate. The same question applies to removing a node. Where are these events?

Thanks,
Marco.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

≈。彩虹 2025-01-07 23:43:04

那么您想在添加子项时执行代码吗?我通过创建自己的小函数来添加节点来做到这一点。

function addChildNode(NodeID, NodeName, ParentID){
    jQuery("#tree2").dynatree("getTree").getNodeByKey(ParentID).addChild({title: NodeName, key: NodeID});

    //Code you wish to be executed goes here

}

然后,您只需调用该函数并传入 NodeID(键)、NodeName(标题)、ParentID(键)即可。

So you want to execute code when you add a child? I did this by creating my own little function to add Nodes.

function addChildNode(NodeID, NodeName, ParentID){
    jQuery("#tree2").dynatree("getTree").getNodeByKey(ParentID).addChild({title: NodeName, key: NodeID});

    //Code you wish to be executed goes here

}

Then you simply call the function and pass in the NodeID (key), NodeName (title), ParentID (key).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文