javascript - jsTree 3.3.2 - 如何配置 jsTree 以便只有一些节点是可拖动的并且可以在特定级别删除

标签 javascript jquery jstree

我有一棵这样的树:

ROOT
|---n1-1
      |---n2-1
            |---n3-1
      |---n2-2
            |---n3-2
|---n1-2
      |---n2-3
      |---n2-4
            |---n3-3
            |---n3-4

是否可以配置 jsTree,以便只有 n3-x 个节点可拖动,并且它们只能作为 n2-x 个节点的子节点被删除?

最佳答案

关于 jsTree 的 documentation ,它指出了名为 $.jstree.defaults.dnd.is_draggable 的拖放插件的配置选项:

A function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) and the event that started the drag - return false to prevent dragging

您应该能够编写一个函数来检查它是否是 n3-x 节点。

不幸的是,我没有看到任何关于指定它可以在文档中放置的位置的内容,但看起来 StackOverflow 的其他地方有人已经解决了这个问题:dnd, how to restrict dropping to certain node types?

关于javascript - jsTree 3.3.2 - 如何配置 jsTree 以便只有一些节点是可拖动的并且可以在特定级别删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39119358/

相关文章:

javascript - 将我的 jquery .load 转换为 .ajax

javascript - 在 Phonegap/ApacheCorova 和 Ionic 框架中构建移动应用程序是否必须使用 Angular.js?

javascript - 使用特定目录将管道文件吞入 zip

javascript - 从数组中随机选择对

c# - 使用jsTree作为文件夹浏览器

javascript - 如何在 jstree 上创建静态节点?

javascript - 下拉菜单未以选定的下拉按钮为中心

javascript - 来自数据库数据的内容可更改 Dropdownlist

jquery - 消除使用 twitter bootstrap 事件创建的警报

jquery - 使用 jsTree 进行延迟加载