Is it right to override the fetch () and save () functions directly from the model?

I do not want to override Backbone.sync(), as some of my models will use the standard one sync().

Is it good to redefine fetch()and save()directly from the model?

+5
source share
1 answer

No need to redefine syncglobally. You can do this for a model / collection, i.e.

var MyModel = Backbone.Model.extend({
    sync: customSync,
    ...
});

This avoids overriding Backbone.sync globally.

Now, if you do not need to perform full synchronization, for example, you only need to override fetch, you can, of course, do this on the basis of the model.

, , Backbone.sync localStorage. ( , ). sync /.

+4

All Articles