2

How I can clear the cache of relational Backbone? relational backbone remembers the previous values ​​after fetch

mstafkmx
  • 419
  • 5
  • 17

3 Answers3

3
Backbone.Relational.store.reset()
jax
  • 37,735
  • 57
  • 182
  • 278
0
Backbone.Relational.store.reset();
models.fetch({
  data: {...},
  reset: true,
  success: function(models) {...}
});

Thanks @jax.

mstafkmx
  • 419
  • 5
  • 17
0

Backbone.Relational.store.reset() removes also registered relations. If you want to clear the cache of stored models only, use this:

Backbone.Relational.store._collections.forEach(function each(collection) {
    collection.reset();
});
Hugo Mallet
  • 533
  • 5
  • 8