dynatree 1 (перетаскиваемый)
$("#tree").dynatree({
dnd: {
revert: false, // true: slide helper back to source if drop is rejected
onDragStart: function(node) {
},
onDragStop: function(node) {
}
},
cookieId:"dynatree-cb1",
idPrefix:"dynatree-cb1-"
});
Dynatree 2 (Droppable)
$("#tree2").dynatree({
dnd: {
autoExpandMS: 1000,
preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
onDragEnter: function(node, sourceNode) {
if(node.data.isFolder){
return false;
}
return true;
// return "over";
},
onDragOver: function(node, sourceNode, hitMode) {
},
onDrop: function(node, sourceNode, hitMode, ui, draggable) {
logMsg("tree.onDrop(%o, %o)", node, sourceNode);
var copynode;
if(sourceNode) {
copynode = sourceNode.toDict(true, function(dict){
dict.title = "Copy of " + dict.title;
delete dict.key; // Remove key, so a new one will be created
});
}else{
copynode = {title: "This node was dropped here (" + ui.helper + ")."};
}
if(hitMode == "over"){
// Append as child node
node.addChild(copynode);
// expand the drop target
node.expand(true);
}else if(hitMode == "before"){
// Add before this, i.e. as child of current parent
node.parent.addChild(copynode, node);
}else if(hitMode == "after"){
// Add after this, i.e. as child of current parent
node.parent.addChild(copynode, node.getNextSibling());
}
},
onDragLeave: function(node, sourceNode) {
/** Always called if onDragEnter was called.
*/
logMsg("tree.onDragLeave(%o, %o)", node, sourceNode);
}
},
cookieId:"dynatree-cb2",
idPrefix:"dynatree-cb2-"
});
Попробуйте этот код, он работает. Я делал то же самое раньше.