A Backbone app which I’m developing has a collection and a model, and associated views for each item.
https://gist.github.com/2255959
When I click on the PostView, unexpectedly, the event fires on the collection without any wiring.
I figured I’d need to bind an event to the model, then have that fire an event on the collection. Is that not the case? Does a collection automagically inherit events fired its child models?
I’m uncertain, but I think it has something to do with the nested views, and maybe the event is being bound on both places instead of just the inner el.
From the fine manual:
So yes, the collection listens to events on all of its models and forwards them.
For example, given a simple set up like this:
Doing
c.first().set(...)will trigger the event handler.Demo: http://jsfiddle.net/ambiguous/wwjnK/