正在获取和分析集合
Fetching and Parsing Collection
我已经重写了正在获取的集合的parse
函数,如下所示:
parse: function(response) {
this.total = response.total;
return response.items;
}
此外,我已经将集合绑定到使用它的视图的渲染函数。this.collection.bind('reset', this.render);
集合本身是在集合的初始化函数中提取的:this.collection.fetch({ data: params });
然后在子视图中访问集合:
render: function() {
var catalog, pages;
catalog = new App.Views.Catalog({collection: this.collection});
pages = new App.Views.Pages({collection: this.collection});
return this;
}
注意:
我能让它工作的唯一方法是将绑定更改为:this.collection.bind('add', this.render);
,它最终调用render
四次。
您可能需要将this
绑定到渲染函数。更改:
this.collection.bind('reset', this.render);
收件人:
this.collection.bind('reset', this.render, this);
相关文章:
- 如何使用backbone.js从集合中获取模型名称
- 主干-从模板中迭代的集合中获取特定的模型
- 获取Href的集合
- 尝试从集合中获取特定模型
- Backbone集合:如何从API中获取特定对象以放置在模型中
- 如何获取jQuery集合中的第k个元素..作为JQUERY元素
- 所需响应的主干无限集合获取调用
- Backbonejs最简单的集合获取
- 主干.js:仅添加来自 JSON 集合获取的新模型
- 我无法使用 lodash _.template 从一个主干视图中的多个集合获取数据
- Backbone.js集合获取'这个_byId'未定义
- 使用特定的ajax调用设置集合获取
- 在 Backbone 中使用相同类型的集合获取不同的模型集
- 使用主干集合获取数据子集
- 主干集合获取选项不影响GET请求
- 从backbone.js集合获取model.id使用Tastypie创建成功调用
- Onchange集合获取错误而不是函数
- 主干集合获取抛出id错误
- 从mongodb集合获取所有文档时出错
- 从服务器上的Meteor集合获取项目会抛出“;可以't wait without Fiber”;