marionettejs / backbone.marionette

The Backbone Framework
https://marionettejs.com
Other
7.06k stars 1.26k forks source link

Marionette 1.0.2 with Backbone 1.0 does not respond to collection reset event. #550

Closed fizerkhan closed 10 years ago

fizerkhan commented 11 years ago

I have listened for an collection events in my View by

collectionEvents: {
            'reset': 'render',
        },

It works well with backbone 0.9.9, but not with backbone 1.0.

Moreover, in CompositeView, onCompositeCollectionRendered does not called after rendered the collection

onCompositeCollectionRendered: function() {
            if (this.collection && this.collection.length > 0) {
                this.$('table').footable();
            }
   },
existentialism commented 11 years ago

In Backbone v1.0.0+, for the reset event to fire on your collection post-fetch, pass reset: true.

See the updated docs: http://backbonejs.org/#Collection-fetch

fizerkhan commented 11 years ago

@existentialism marionette should handle this right?

existentialism commented 11 years ago

@fizerkhan sorry for late reply, somehow fell through the cracks... but I don't think this is Marionette's responsibility.

Aren't you calling your own @collection.fetch()?

fizerkhan commented 11 years ago

@existentialism Thanks for the reply. Why onCompositeCollectionRendered does not work?. Marionette docs says it will be invoked if all items in collection has been rendered. But it does not called with backbone 1.0

ingro commented 11 years ago

It does not because it is bound to the collection reset event wich isn't fired if you don't pass reset: true as argument when you call fetch(). You should listen to the collection event sync if you wanna know when an update without a reset has been called.

fizerkhan commented 11 years ago

@ingro Thanks, It works now. But migration from backbone 0.9.9 to backbone 1.0 needs this changed in all collection fetch. It will be nice if it is added in the documentation.

cobbweb commented 10 years ago

Fixed by #576.