BackboneJS collection.reset() vs collection.fetch()

后端 未结 3 869
北荒
北荒 2021-02-04 05:41

I have read and read the docs on these two methods, but for the life of me cannot work out why you might use one over the other?

Could someone just give me a basic code

3条回答
  •  [愿得一人]
    2021-02-04 06:07

    reset() is used for replacing collection with new array. For example:

    @collection.reset(@full_collection.models)
    

    would load @full_collections models, however

    @collection.reset()
    

    would return empty collection. And fetch() function returns default collection of model

提交回复
热议问题