所以目前我所有的收藏和模型都来自服务器休息 api 并且工作正常。
我使用最新的 Backbone.localStorage.js
现在我想要几个模型只保存到 localStorage。我不确定我需要在这里做什么,这就是我只想使用 localstorage 的模型和集合。
class Upload extends Backbone.Model
class Uploads extends Backbone.Collection
localStorage: new Backbone.LocalStorage 'uploads'
initialize: =>
@model = Upload
sync:(method, model, options) =>
return Backbone.localSync.call(model, method, model, options)
所以做完之后 ny 集合总是空的
model = new Upload(name:foo)
collection = new Uploads
collection.add(model)
console.log collection shows it has one model here, but logging on the sync overide its empty again