Dojo abort drag/drop operation in dnd/drop/before
I wanted to know if there is a way I can abort the default drop operation in dojo. I am doing some custom manipulation开发者_JAVA百科 in the function,
dojo.subscribe("/dnd/drop/before", function(source, nodes, iscopy){
//Custom manipulation
});
And from this function, I want to cancel the drop, similar to what happens when you press the Esc Key?
Thanks
You can publish the topic dnd/cancel
, i.e. dojo.publish('/dnd/cancel')
, then call dojo.dnd.manager().stopDrag()
to cancel the drop.
But the recommended way is to customize the checkAcceptance()
of dojo.dnd.Source
to return false
when current node is not droppable. Find more details in dojo dnd's doc.
For me, overriding onDrop
works like a charm. Accourding to doc, i have something like:
var source2 = new dojo.dnd.Source("source", {
onDrop : function(source, nodes, copy) {
if (canProceedCondition) {
this.onDropExternal(source, nodes, copy);
}
}
});
精彩评论