Skip to main content

Bug Tracker

Side navigation

#11681 closed bug (duplicate)

Opened May 01, 2012 09:29PM UTC

Closed May 01, 2012 09:37PM UTC

Last modified May 01, 2012 09:37PM UTC

Missing dataTransfer object

Reported by: dilvie@dilvie.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

I tried accessing the dataTransfer object on an event in order to implement HTML5 drag and drop, and was surprised to find that the key is not on the event object. It is, however on the originalEvent key. I don't understand why jQuery's event object doesn't inherit that key from originalEvent. It seems inconsistent with the rest of the event API.

Attachments (0)
Change History (3)

Changed May 01, 2012 09:34PM UTC by anonymous comment:1

jQuery 1.7.2

Google Chrome / OS X Lion

To reproduce: add a draggable="true" attribute to any element, and then set up event delegation on the element. The following code fails, because the dataTransfer key is undefined:

$el.delegate('[draggable="true"]', 'dragstart', function (event) {

event.preventDefault();

event.dataTransfer.effectAllowed = 'copy';

event.dataTransfer.setData('Text', this.id);

}

Workaround:

change event.dataTransfer to event.originalEvent.dataTransfer

Changed May 01, 2012 09:37PM UTC by rwaldron comment:2

resolution: → duplicate
status: newclosed

This is not a bug. For special properties, please use the evvent.originalEvent object.

Changed May 01, 2012 09:37PM UTC by rwaldron comment:3

Duplicate of #7808.