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.
相关问题
- How do I get a jstree node to display long, possib
- jsTree Object has no method addBack
- Adding jQuery custom image tool tip to jsTree
- Remove node by ID in jstree when button is clicked
- jstree delete_node() is not deleting
The above approaches do not work with the latest versions of jstree (3.3.7 as of today).
The first line of Bojin's answer still holds true. To implement rules, you can use
core.check_callback
or possibly, thetypes
plugin; thecrrm
plugin doesn't exist anymore. Bind tomove_node.jstree
to perform some action on completion of move (drop). By default, the dnd plugin allows re-ordering (dropping between two nodes) and copying (Ctrl + drag), in addition to moving a node. The code snippet below shows how to disable these additional behaviors.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.
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 andm.r
refers to your destination node.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: