我有一棵这样的树:
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/