18

This is driving me mad.

Please forgive me but I'm not going to post the full code as it is (I believe) irrelevant. The reason behind this is obviously with my code. I was getting the following error:

draggable / droppable dataTransfer is undefined

So I decided to copy the source from:

http://jqueryui.com/droppable/#photo-manager

and I still get the same error.

I am using the latest jQuery UI with all packages included.

Does anyone know why this happens but not on the jQuery UI example?

Regards.

extempl
  • 2,987
  • 1
  • 26
  • 38
Phil Jackson
  • 10,238
  • 23
  • 96
  • 130
  • If you could provide a link to where this is happening you, or provide the full source (jsfiddle.net is good for that) you would increase the likelihood of an accurate answer. – John Keyes Oct 03 '11 at 20:32

2 Answers2

72

To solve this problem you must add this line:

e.dataTransfer = e.originalEvent.dataTransfer;

before the error line. This should fix it.

Alaa Badran
  • 1,848
  • 15
  • 19
  • 2
    Would you be able to give me some sort of direction as to why you might need the originalEvent part? Doesnt js like it if you pass the event from function to function to function etc... – Marais Rossouw Dec 30 '14 at 10:58
  • 6
    I found an answer in [this thread](http://stackoverflow.com/questions/11885900/difference-between-event-originalevent-datatransfer-files-and-event-datatransfer): "jQuery does not pass the browser event object to you, it passes the jQuery event object. You can access the original untouched event object by the .originalEvent property in the jQuery event object." – Godsmith Mar 05 '16 at 18:42
6
$.event.props.push('dataTransfer');
chikamichi
  • 2,199
  • 1
  • 24
  • 16