1
私はbackbone.jsの初心者です。非常に基本的なダミーの例が正常に動作しません。私はそれが愚かな間違いの結果だと確信していますが、どんな指導にも感謝します。ここで バックボーンコレクションにデータが入力されない
は私のjavascriptです:ここではvar lr = lr || {};
lr.Event = Backbone.Model.extend({});
lr.Events = Backbone.Collection.extend({
model: lr.Event,
url: '/json/dummy.json'
});
lr.EventView = Backbone.View.extend({
tagName: 'div',
initialize: function() {
_.bindAll(this, "render");
this.collection = new lr.Events();
this.collection.fetch();
console.log(this.collection.toJSON());
this.render();
},
render: function() {
}
});
lr.ev = new lr.EventView();
あるJSON/dummy.json:
[
{ "title": "Event1", "Location": "New York, NY" },
{ "title": "Event2", "Location": "Cleveland, OH" }
]
私は、これはJSONをCONSOLE.LOGことを期待するが、それは代わりにconsole.logは空ですアレイ。私は間違って何をしていますか?