gmac / backbone.epoxy

Declarative data binding and computed models for Backbone
http://epoxyjs.org
MIT License
615 stars 89 forks source link

Epoxy should listen to collection 'change' event #65

Closed nadavvin closed 10 years ago

nadavvin commented 10 years ago

if collection's model change, Epoxy not update the template. when model is change , the collection change trigger is also throw.

this.listenTo(this.collection, "change", function(){console.log("update");}, this);

Prinzhorn commented 10 years ago

This is documented here http://epoxyjs.org/documentation.html#handler-collection

Note that the collection binding does not register a "change" event on its collection to avoid generally superfluous updates. Instead, you may manually trigger an "update" event on the collection to refresh its bindings. For a working demonstration of the collection binding, see the Epoxy ToDos demo.

Could you explain your use case? Usually the collection does not need to react to individual model changes.

gmac commented 10 years ago

@Prinzhorn is right. That's exactly why Epoxy doesn't listen to Collection changes... A collection doesn't have a native change trigger, it simply proxies those of its models. As a result, a lot of collection-specific behavior would be triggered by model-specific events. I take it you're trying to bind a template to a collection? I'd suggest using templates with individual models. The docs should be updated to reflect that.