2012-01-30 98 views
0

我重写的集合,我取的这样的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四次。

+0

我现在的答案可能不会解决问题。你可以在获取对象的地方发布更多的代码,以及试图查看'this.total'的值吗? – 2012-01-30 19:11:46

回答

0

您可能需要将this绑定到渲染函数。更改:

this.collection.bind('reset', this.render); 

要:

this.collection.bind('reset', this.render, this); 
+0

我应该提到我有:'_.bindAll(this,'render')''this.collection.bind('reset',this.render)' – Ari 2012-01-30 21:57:01

+0

OK。你是否介意发布更多的代码,特别是在调用了获取的地方,以及在哪里可以看到总共未设置的问题? – 2012-01-31 15:15:17