I have backbone collection and under some circumstances I am fetching more models into the collection with:
collection.fetch({data: {...}, add: true});
I need view of the collection to be re-rendered when new members arrive.
“reset” event is not fired because of add:true parameter hence I see two options.
- Bind this.render function to collection’s “add” event. This is work but makes render function to be called for each new model arrived from server.
- Pass silent:true as fetch parameter and call this.render() explicitly in next line, however at next line data still not arrived, hence render function called with old data.
I haven’t found any other way to overcome the issue 🙁
Any advises what should I do in this case?
you can also pass
successcallback as option to the fetch method and trigger full rerender after successful ajax operation if this is your preferred way of doing it// or reference to function – you get the drill