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

ash*_*ram 7 javascript jstree

我们使用jsTree来表示文件和文件夹.文件和文件夹可以从其他文件夹移入和移出.

为此,我启用了拖放插件.可以拖放文件夹和文件,但不会调用拖放时调用的事件.

我需要在拖放时触发这些事件,因为我需要使用Ajax更新后端拖放的状态.

请帮忙

下面是代码.

<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"
                    }
                }

            }
        }



    });
});
Run Code Online (Sandbox Code Playgroud)

我是否遗漏了任何东西,或者还有什么我需要做的,以便调用拖放事件?

Nag*_*h M 6

检查此URL 使用JSTree拖放问题 使用class ="jstree-drop"以及所有节点的ID.它会工作.例如: - 如果使用json数据

"plugins" : [ "core", "json_data", "themes", "ui","dnd"],
{
    {id : "id1",rel : "folder",class:"jstree-drop"},
    data:"New folder2",
    state:"closed"
}
Run Code Online (Sandbox Code Playgroud)

如果我们使用html数据,则将class ="jstree-drop"添加到所有节点.然后"drop_finish"事件将正常工作,但不是drag_check,drag_finish.我尝试在css类中添加jstree-drag.

更新(2011年7月19日一小时后): - 为所有元素添加jstree-draggable css类拖动事件也可以更好地工作http://www.jstree.com/documentation/dnd


bjo*_*rnd 3

如果您想将节点拖动到树内部,您应该使用CRRM 插件,而不是 DND。DND 用于在树外或树之间拖动节点。