Dojo abort a drag operation in dnd / drop / before

I wanted to know if there is a way to cancel the default operation in dojo. I am doing some user manipulation in a 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?

thank

+3
source share
2 answers

You can post a topic dnd/cancel, i.e. dojo.publish('/dnd/cancel'), then call dojo.dnd.manager().stopDrag()to cancel the deletion.

But the recommended way is to configure checkAcceptance()of dojo.dnd.Sourceto return falsewhen the current node is not disconnected. See dojo dnd doc for details .

+2
source

onDrop . Accourding to doc, - :

var source2 = new dojo.dnd.Source("source", {
        onDrop : function(source, nodes, copy) {
            if (canProceedCondition) {
                this.onDropExternal(source, nodes, copy);
            }           
        }
    });
+1

Source: https://habr.com/ru/post/1754659/


All Articles