【发布时间】:2012-03-08 02:14:10
【问题描述】:
我有一个表,当新项目添加到集合中时我正在填充该表,当从该集合中删除项目时,我会填充已删除的项目集合。
然后我有一个保存按钮,它触发集合上的保存/删除事件。
保存工作正常,但我的删除只有一半工作,我很困惑。
class MyApp.Collections.DeletedTasks extends Backbone.Collection
model: MyApp.Models.Task
destroy: () ->
console.log('destroy the collection size: ' + @.models.length)
_.each(@.models, @sendDelete)
sendDelete: (model) ->
console.log('deleting model with id: ' + model.get('id'))
model.destroy()
控制台输出
Done with Adding/Updating Collections
destroy the collection size: 6
deleting model with id: KSc18d06fefddbebd2ade74bcab4c670c907
deleting model with id: KS07cb95935b1caf3817758739224a3e1a2f
deleting model with id: KS6f473b3e15740fe7c6c0909e14986700a9
发生了什么? 为什么它只做了3? 我该如何调试?
感谢任何帮助!
【问题讨论】:
标签: javascript backbone.js coffeescript underscore.js each