Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Backbone's event obj have missing properties?

I was working on some drag/drop functionality and was attaching events through the standard Backbone way:

events: { 
 'dragenter': 'dragEnter',
 'dragend': 'dragEnd'
 ....,
 .....
}

I noticed in my function that the event object that is passed into it doesn't contain some properties outlined in the html5 spec.

Specifically, the dataTransfer obj is missing.

I created a quick demo to demonstrate my issue. Just drag a file or something over it to see it in the logs.

My question is why does this happen? I have looked through the documentation and can't seem to find it.

like image 773
Mike Fielden Avatar asked Apr 30 '12 16:04

Mike Fielden


1 Answers

If you're using Backbone Events, Backbone puts a layer on top of the actual event. If you want to access the original event you'll have to use: event.originalEvent.

In the originalEvent you'll find dataTransfer.

like image 78
Dossea Iomega Avatar answered Nov 15 '22 04:11

Dossea Iomega