有没有办法从成功事件中引用所有者集合。
例如,我正在使用 this
来引用集合:
var col = Backbone.Collection.extend({
model: MobileService,
url: 'file.json',
initialize: function(){
this.fetch({
success: function(){
this.trigger('fetched');
},
...
最佳答案
来自fine manual :
fetch
collection.fetch([options])
[...] The options hash takes
success
anderror
callbacks which will both be passed(collection, response, options)
as arguments.
所以你可以使用:
this.fetch({
success: function(collection) {
collection.trigger('fetched');
}
});
关于javascript - 如何从 fetch :success event? 中获取这个集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21179483/