我正在構建我的第一個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