View Full Version : Prevent browser default image drag

26 Mar 2014, 6:29 AM

I have a UI with an image on it. A user can start a drag / drop operation by dragging this image. This image element has a Ext.dd.DragZone attached to it. Depending on the state the drag can be started or not. When the state allows the drag operation, the dragZone.getDragData function is used to provide the drag data, so far so good.
But when the state does not allow a drag / drop operation, the dragZone.getDragData returns false. The Ext drag operation is not started ( = ok). But the browsers drag kicks in (default drag / drop of a picture in the browser) and picks the image up.

How can I prevent this default browser image drag?

2 Apr 2014, 10:18 AM
You could use the draggable="false" attribute of the img element. If not possible, you can listen for the dragstart event of the el and prevent the default behavior. How does your code look like?

2 Apr 2014, 10:41 PM
I solved the problem by listening to the Ext.Img dragstart event en prevent the default handling. All images used in the app are now of type Ext.Img. This solved the problem.