我正在构建我的第一个Backbone应用程序,其结构与Todo MVC example类似,具有Require.js并且还使用Backbone LocalStorage。问题是,当我在HomeView运行TweetsCollection.fetch()
,萤火给我的错误:TypeError: options is undefined
var method = options.update ? 'update' : 'reset';
Backbone.js收集提取错误
TweetsCollection:
define([
'underscore',
'backbone',
'backboneLocalStorage',
'models/TweetModel'
], function(_, Backbone, Store, TweetModel) {
'use strict';
var TweetsCollection = Backbone.Collection.extend({
model: TweetModel,
localStorage: new Store('tweets-storage'),
initialize: function() {
console.log('Collection init...');
}
});
return new TweetsCollection();
});
HomeView的init:
initialize: function() {
this.listenTo(TweetsCollection, 'add', this.addOne);
this.listenTo(TweetsCollection, 'reset', this.addAll);
this.listenTo(TweetsCollection, 'all', this.render);
TweetsCollection.fetch(); // <- Error here
},
我尝试按照上面的例子,但我真的迷失了。
谢谢!降级到0.9.9 – Potty