Bug Tracker

Modify

Ticket #11681 (closed bug: duplicate)

Opened 13 months ago

Last modified 13 months ago

Missing dataTransfer object

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

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.

Change History

comment:1 Changed 13 months ago by anonymous

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

comment:2 Changed 13 months ago by rwaldron

  • Status changed from new to closed
  • Resolution set to duplicate

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

comment:3 Changed 13 months ago by rwaldron

Duplicate of #7808.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.