嵌套数组的骨干集合

时间:2015-02-03 10:42:01

标签: javascript arrays backbone.js

如何从嵌套数组中进行收集?这就是数组之前的样子:

enter image description here

var OrdersCollection =  Backbone.Collection.extend({
      model: OrderModel,
      url : '/api/orders',
});

var OrderModel = Backbone.Model.extend({});


var orders = this.model;
this.collection = new OrdersCollection(orders);

现在我的数组如下:

enter image description here

所以我必须从行内的数组中进行收集...感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

使用.parse

var OrdersCollection =  Backbone.Collection.extend({
      model: OrderModel,
      url : '/api/orders',
      parse: function(response) {
        return response.rows;
      }
});