admin管理员组文章数量:1293520
So I understand we can do something like this:
Collection.fetch({success: function() { bla.. } } )
But say I wanted something like this:
Collection.fetch( { success: function () { if (condition) { this.fetch() } }})
The problem is, the second time I call fetch (the one in bold), it won't have the success function associated with it. What I want to do is: Call fetch until that condition bees true...that condition is based on the data (result) of the previous fetch.
Anyone?
So I understand we can do something like this:
Collection.fetch({success: function() { bla.. } } )
But say I wanted something like this:
Collection.fetch( { success: function () { if (condition) { this.fetch() } }})
The problem is, the second time I call fetch (the one in bold), it won't have the success function associated with it. What I want to do is: Call fetch until that condition bees true...that condition is based on the data (result) of the previous fetch.
Anyone?
Share asked Jan 12, 2012 at 3:26 UserXYZUserXYZ 2233 silver badges14 bronze badges 1- 1 possible duplicate of backbone.js collection - Calling fetch repeatedly to get all "pages" from server – kubetz Commented Jan 12, 2012 at 3:40
1 Answer
Reset to default 9You could declare the function outside of the parameter like so, this way you can reference it later.
var collection = new Backbone.Collection();
var success = function(){
if(condition){
collection.fetch({success : success});
}
};
collection.fetch({success : success});
本文标签:
版权声明:本文标题:javascript - backbone.js collections - How to define a success callback for fetch (recursive though) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741581066a2386574.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论