【发布时间】:2011-05-24 05:07:23
【问题描述】:
我们使用 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"
}
}
}
}
});
});
为了调用拖放事件,我是否遗漏了什么或者我需要做些什么?
【问题讨论】:
标签: javascript jstree