0

I bind the collection to a DOM element '#collection_view'.

When collection fetching data and update the view, the view changed to be EMPTY for a second and then filled with correct HTML. In the collection there are addAll, addOne methods to append list element to the list.

How can I skip the empty, replace old HTML with new HTML directly?

mu is too short
  • 426,620
  • 70
  • 833
  • 800
Bruce Dou
  • 4,673
  • 10
  • 37
  • 56

1 Answers1

0

This is how fetch() works.. it will empty the collection and addAll elements at once. I suppose you have a this.$el.empty() call (or something like) in your addAll event binding function. And what is happening is that the $el DOM element will be cleaned and after that repopulated.

If you want to refresh a collection instead of reset it you should check the answers here.

Looks like someone proposed to add this soft update to the Backbone Collection but was denied by Backbone maintainers.

Community
  • 1
  • 1
fguillen
  • 36,125
  • 23
  • 149
  • 210