jstree移动,拖放 [英] jstree move, drag and drop

查看:144
本文介绍了jstree移动,拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为jstree中的节点实现移动功能.是需要执行的动作还是拖放?同样,最好有用于将容器绑定到事件的有效代码以及事件代码.

I want to implement the move functionality for a node in jstree. Is it the move that needs to be implemented or the drag and drop? Also, it would be nice to have working code for binding the container to event and the event code.

推荐答案

仅在不需要执行任何移动规则(不允许将某些节点移动到其他节点等)时,才需要使用dnd插件. ) 如果您需要执行移动规则,则可以添加crrm插件.

You only need to use the dnd plugin if you don't need to enforce any move rules(don't allow certain nodes to be moved to other nodes etc) If you need to enforce move rules, you can add the crrm plugin.

有关此示例,请参见dnd pluign文档的仅重新排序演示.该文档非常差,因此您必须使用浏览器上的开发人员工具来查看check_move回调参数的属性.对于文档中的示例,m.o表示您的拖动节点,而m.r表示您的目标节点.

See the Reorder only demo of the dnd pluign documentation for an example of this. The documentation is very poor, so you will have to use the developer tool on your browser to see what the properties of the parameter for the check_move callback are. For the example in the documentation, m.o refers to your dragged node and m.r refers to your destination node.

您还可能需要在移动节点时得到通知,因此在初始化树时绑定到move_node.jstree事件:

You will also likely need to be notified when a node is moved, so bind to the move_node.jstree event when you initialize the tree:

  $("#treeHost").jstree({
  ...
  }).bind("move_node.jstree", function (e, data) {
        // data.rslt.o is a list of objects that were moved
        // Inspect data using your fav dev tools to see what the properties are
        });
    })

这篇关于jstree移动,拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆