Backbone 来自嵌套数组的集合
Backbone collection from nested array
如何从嵌套数组中创建集合?这是数组之前的样子:
var OrdersCollection = Backbone.Collection.extend({
model: OrderModel,
url : '/api/orders',
});
var OrderModel = Backbone.Model.extend({});
var orders = this.model;
this.collection = new OrdersCollection(orders);
现在我有这样的数组:
所以我必须从行内的数组中收集...感谢您的帮助!
使用.parse
var OrdersCollection = Backbone.Collection.extend({
model: OrderModel,
url : '/api/orders',
parse: function(response) {
return response.rows;
}
});
如何从嵌套数组中创建集合?这是数组之前的样子:
var OrdersCollection = Backbone.Collection.extend({
model: OrderModel,
url : '/api/orders',
});
var OrderModel = Backbone.Model.extend({});
var orders = this.model;
this.collection = new OrdersCollection(orders);
现在我有这样的数组:
所以我必须从行内的数组中收集...感谢您的帮助!
使用.parse
var OrdersCollection = Backbone.Collection.extend({
model: OrderModel,
url : '/api/orders',
parse: function(response) {
return response.rows;
}
});