简体   繁体   English

jstree中dnd插件中的拖放事件没有被调用

[英]Drag and Drop events in dnd plugin in jstree are not getting called

We are using jsTree for tree representation of the Files and folders.我们使用 jsTree 来表示文件和文件夹。 Files and folders can be moved in and out from other folders.文件和文件夹可以从其他文件夹移入和移出。

For this I have enabled the drag and drop plugin.为此,我启用了拖放插件。 The folders and files can be dragged and dropped but the events which are called on drag and drop are not getting called.可以拖放文件夹和文件,但不会调用拖放时调用的事件。

I need these events to fire on drag and drop as I need to update the status of the drag and drop in the backend using Ajax.我需要在拖放时触发这些事件,因为我需要使用 Ajax 在后端更新拖放状态。

Please help请帮忙

Below is the code.下面是代码。

<script type="text/javascript" class="source">

$(function() {

        $("#folderTree").jstree( {
        "dnd" : {
            "drop_finish" : function () { 
                alert("DROP"); 
            },
            "drag_check" : function (data) {
                if(data.r.attr("id") == "phtml_1") {
                    return false;
                }
                return { 
                    after : false, 
                    before : false, 
                    inside : true 
                };

                alert("hhh jjj kk ");
            },
            "drag_finish" : function () { 
                alert("DRAG OK"); 
            }
        },

        "plugins" : [ "core", "html_data", "themes", "ui","dnd"],

        "ui" : {
            "initially_select" : [ "phtml_1" ]
        },

        "core" : { "initially_open" : [ "phtml_1" ] },

        "themes" : {
                "theme" : "apple"
        },

        "types" : {
            "valid_children" : [ "root" ],
            "types" : {
                "root" : {
                    "icon" : { 
                        "image" : "../images/drive.png" 
                    },
                    "valid_children" : [ "folder" ],
                    "draggable" : false
                },
                "default" : {
                    "deletable" : false,
                    "renameable" : false
                },

                "folder" : {
                    "valid_children" : [ "file" ],
                    "max_children" : 3
                },
                "file" : {
                    // the following three rules basically do the same
                    "valid_children" : "none",
                    "max_children" : 0,
                    "max_depth" : 0,
                    "icon" : {
                        "image" : "../images/file.png"
                    }
                }

            }
        }



    });
});

Am I missing anything or is there anything else I need to do in order for the drag and drop events to get called?为了调用拖放事件,我是否遗漏了任何东西或者我需要做些什么?

Check with this URL Issue with JSTree drag drop Use class="jstree-drop" along with IDs for all the nodes.检查此 URL问题与 JSTree 拖放使用class="jstree-drop"以及所有节点的 ID。 It will work.它会起作用的。 For example:- If you use json data例如:- 如果您使用 json 数据

"plugins" : [ "core", "json_data", "themes", "ui","dnd"],
{
    {id : "id1",rel : "folder",class:"jstree-drop"},
    data:"New folder2",
    state:"closed"
}

if we use html data then add class="jstree-drop" to all nodes.如果我们使用 html 数据,则将class="jstree-drop"添加到所有节点。 Then "drop_finish" event will works fine, but not drag_check,drag_finish.然后 "drop_finish" 事件会正常工作,但不是 drag_check,drag_finish。 I tried by adding jstree-drag in css class.我尝试在 css class 中添加 jstree-drag。

Updated (after one hour on 19th-July-2011):- add jstree-draggable css class to all elements drag events also works fine more information http://www.jstree.com/documentation/dnd更新(2011 年 7 月 19 日一小时后):- 添加jstree-draggable css class 到所有元素拖动事件也可以正常工作更多信息Z80791B3AE7002CB88C246876D9FAAF/documentation.8/

If you want to drag nodes inside of the tree you should use CRRM plugin , not DND.如果要在树内拖动节点,则应使用CRRM 插件,而不是 DND。 DND is used to drag nodes outside the tree or between the trees. DND 用于将节点拖到树外或树之间。

Options dnd.drag_check , dnd.drag_finish , dnd.drop_finish is uses for foreign objects .选项dnd.drag_checkdnd.drag_finishdnd.drop_finish用于异物 For manage moving inside one tree (or between trees) use crrm.move.check_move .要管理在一棵树内(或树之间)的移动,请使用crrm.move.check_move

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM