Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling copying in dojo.dnd

By default a dojo.dnd.Source container allows you to hold Ctrl to duplicate/copy a dragged item rather than just move it.

I know you can set singular=true to stop multiple items being dragged but how do I stop copying? Duplicating items makes no sense in the context of my items (I am making a draggable list for reordering pages on a website menu).

Thanks

like image 851
voidstate Avatar asked Jan 04 '11 16:01

voidstate


1 Answers

I'm unsure if there's a nicer way, but I've always accomplished this by clobbering the copyState method on the Source instance to always return false.

If you've got several Sources on the page, you could also elect to dojo.declare a subclass with the method overridden, or dojo.extend dojo.dnd.Source itself to clobber the method in all instances.

like image 76
Ken Franqueiro Avatar answered Sep 20 '22 17:09

Ken Franqueiro