I have a Backbone Collection initialized by running collection.fetch() method, and then after a while, I asked the collection to fetch again in order to refresh the models. so, is there any event from Model fired that I can subscribe from View in order to remove/update the view.
I have a Backbone Collection initialized by running collection.fetch() method, and then after a
Share
There isn’t a specific “the collection has been refetched” event but you don’t need one.
fetchresets the collection:And
resettriggers a"reset"event:So just listen for
"reset"events from the collection and re-render the view when you get one.The behavior of
fetchchanged in Backbone 1.0, from the ChangeLog:And if we look at
set:So you can say
collection.fetch({ reset: true })if you want to keep using the"reset"event or you cancollection.fetch()and listen for individual"add","remove", and"change"events.