A
A
Alexander Zim2015-05-01 09:41:15
JavaScript
Alexander Zim, 2015-05-01 09:41:15

What is the best way to implement collection reacquisition in Backbone.js?

There is a collection. During initialization, the fetch method is simply called, which successfully downloads all models and everything works as it should. But it is necessary to implement a function that will update this collection. It should not completely reset the model, but leave the models that have 'locked' set to true, and replace the rest with new ones.
So I want to make sure that the normal solution to the problem is to create a method that will not use backbone synchronization methods, but simply check each model for the presence of locked: true, remove unnecessary ones, make a request through regular jquery and add some models manually, so how to come up with an implementation with backbone methods of synchronization, it doesn’t work for me here.
Sorry if I'm asking something stupid or explained very unclearly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Prozorov, 2015-05-01
@3um

The fetch method can be passed the data option in which to specify the conditions for fetching data. Also, there you can determine the reaction of the collection to new models and those that have already been. Everything is described in detail here: backbonejs.ru/#Collection-fetch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question