Backbone.js Events And El
Okay, so I've read several other questions regarding Backbone views and events not being fired, however I'm still not getting it sadly. I been messing with Backbone for about a da
Solution 1:
Your problem is that the events on GridView:
events: {
'click .grid-view': 'okay'
}
say:
when you click on a descendent that matches
'.grid-view'
, callokay
The events are bound with this snippet from backbone.js
:
if (selector === '') {
this.$el.on(eventName, method);
} else {
this.$el.on(eventName, selector, method);
}
So the .grid-view
element has to be contained within your GridView's this.el
and your this.el
is <div class="grid-view">
. If you change your events
to this:
events: {
'click': 'okay'
}
you'll hear your cows (or "hear them in your mind" after reading the alert depending on how crazy this problem has made you).
Fixed fiddle: http://jsfiddle.net/ambiguous/5dhDW/
Post a Comment for "Backbone.js Events And El"