我們使用jsTree來表示文件和文件夾。文件和文件夾可以從其他文件夾移入和移出。jstree中的dnd插件中的拖放事件沒有被調用
爲此,我啓用了拖放式插件。可以拖放文件夾和文件,但拖放時調用的事件不會被調用。
我需要這些事件來進行拖放操作,因爲我需要使用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"
}
}
}
}
});
});
我失去了什麼或有什麼事我需要爲了做拖放事件被調用?
感謝您的回覆。使用CRRM插件,我可以在樹內拖放節點嗎?我不想有任何按鈕來執行這些文件和文件夾的移動。 – ashishjmeshram 2011-05-24 05:56:09
我這種情況下你需要一起使用它們。看看該演示和代碼http://www.jstree.com/documentation/dnd#demo2。 – bjornd 2011-05-24 06:01:24