Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 拖放;在两个痴迷者之间_Javascript_Jquery_Fancytree - Fatal编程技术网

Javascript 拖放;在两个痴迷者之间

Javascript 拖放;在两个痴迷者之间,javascript,jquery,fancytree,Javascript,Jquery,Fancytree,是否有一种方法可以组合两个Fancytree,即Fancytree a是一组固定的配置项,Fancytree B是一个配置文件,并且Fancytree a中的项可以拖放到Fancytree B,而不会在树a中消失。在Fancytree B中,拖放也应该是可能的 我已经找了一段时间了,但还没有找到我想要的东西,所以也许有人知道怎么做 使用标准功能完全可以从不同的树或甚至标准jQueryDraggables中拖放节点 基本上您使用相同的API $("#tree").fancytree

是否有一种方法可以组合两个Fancytree,即Fancytree a是一组固定的配置项,Fancytree B是一个配置文件,并且Fancytree a中的项可以拖放到Fancytree B,而不会在树a中消失。在Fancytree B中,拖放也应该是可能的


我已经找了一段时间了,但还没有找到我想要的东西,所以也许有人知道怎么做

使用标准功能完全可以从不同的树或甚至标准jQuery
Draggables
中拖放节点

基本上您使用相同的API

        $("#tree").fancytree({
            extensions: ["dnd"],
            ...
            dnd: {
                ...
                dragStart: function(node, data) {
                    if( data.originalEvent.shiftKey ){
                        console.log("dragStart with SHIFT");
                    }
                    // allow dragging `node`:
                    return true;
                },
                dragEnter: function(node, data) {
                    // Prevent dropping a parent below another parent (only sort
                    // nodes under the same parent)
/*                  if(node.parent !== data.otherNode.parent){
                        return false;
                    }
                    // Don't allow dropping *over* a node (would create a child)
                    return ["before", "after"];
*/
                   return true;
                },
                dragDrop: function(node, data) {
                    if( !data.otherNode ){
                        // It's a non-tree draggable
                        var title = $(data.draggable.element).text() + " (" + (count)++ + ")";
                        node.addNode({title: title}, data.hitMode);
                        return;
                    }
                    data.otherNode.moveTo(node, data.hitMode);
                }
            }
        });
示例浏览器包含下面的演示