backbone.jsに問題があります。すべてのコードは機能しますが、例外が発生します
TypeError: 'undefined' is not an object (evaluating '(e=this.models[c]).cid')
。
例外は、モデルの数が制限を超えた場合に発生し、コレクションでself.remove()を呼び出します。
var Column = Backbone.Collection.extend({
initialize: function(col) {
var view = new ColumnView({
id: "column_" + col.id,
column: col
});
view.render();
},
comparator: function(tweet) {
return tweet.get('created_at_time');
},
clean: function() {
var self = this;
var total = this.models.length;
var threshold = (total - window.config.threshold) - 1;
if(threshold > 0) {
console.log("Removing if tweet is older then " + threshold);
this.models.forEach(function(tweet, index) {
if(index < threshold) {
self.remove(tweet);
}
});
}
}
});
誰かが何が起こっているのか知っていますか?エラーはサファリで発生します。