我有一个带有以下代码的集合视图:
class FoosCollectionView extends Backbone.View
el: '#foos'
initialize: ->
@collection = new FoosCollection [],
barId: @options.barId
foozId: @options.foozId
@listenTo @collection, 'sync', @render
@collection.fetch()
template: MyApp.Templates.foos
render: (event)->
$(@el).html @template @collection
@
FoosCollectionView
在Backbone 1.0.0之前,当集合上的reset
完成时,会触发fetch
事件。现在触发sync
事件,但我不知道这是由于错误还是新标准行为。
有谁能告诉我,为什么reset
不再被触发?
此致 菲利克斯
答案 0 :(得分:7)
在1.0.0更改日志中,我看到:
重命名Collection的“更新”以设置,与类似的并行 model.set(),与reset对比。 现在是默认更新 获取后的机制。如果您想继续使用“重置”,请通过 {reset:true}。