次のような外部 URL を持つコレクションを作成しています。
var todoCollection = Backbone.Collection.extend({
model: Todo
url: function() {
return "http:externalurl.com";
},
parse: function(dat) {
return dat.obj.data;
}
});
return new todosCollection;
私のモデルは次のようになります。
var TodoModel = Backbone.Model.extend({
initialize: function() {}
});
return TodoModel;
ここで、私の見解では、コレクションを次のように使用します。
$.each(this.collection.models,function(i,model){
console.log(model);
})
問題は、モデルが TodoModel タイプとして設定されていないことです。それらは単純なオブジェクト型です。ここでどこが間違っているのかを教えてくれる人はいますか?
ありがとうございました。