jquerybackbone.jsbackbone-events

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.


Solution

  • 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.