var app = {};
var FoodModel = Backbone.Model.extend({
url: "http://localhost/food"
});
var FoodCollection = Backbone.Collection.extend({
model: FoodModel,
url: "http://localhost/food"
});
var FoodView = Backbone.View.extend({
render: function(){
console.log(this.model.toJSON());
}
});
app.FoodModel = new FoodModel();
app.FoodCollection = new FoodCollection;
app.FoodCollection.fetch();
var myView = new FoodView({model: app.FoodModel})
在這段代碼中,總的console.log數據返回null在this.model骨幹模型空採血後取
如果CONSOLE.LOG收集它充滿數據的,我怎麼能在視圖中獲取this.model以反映集合中的數據?
後端返回什麼? – Roman