这是我收藏的视图:
Network.Views.Offers.Index = Backbone.View.extend({
initialize: function() {
_.bindAll(this, 'render');
this.collection = new Network.Collections.Offers();
this.collection
.on('reset', this.render)
.fetch();
},
render: function() {
var self = this;
_.each(this.collection.models, function(model) {
var view = new Network.Views.Offers.Offer({ model: model });
$(self.el).append(view.el);
view.adjustHeight();
});
return this;
},
});
成功获取后,我尝试添加和删除微调器类:
this.$el.append('<div class="loading">Loading...</div>');
this.collection
.on('reset', this.render)
.fetch({
success:function() {
this.$el.removeClass('loading');
}
});
但我得到:
Uncaught TypeError: Cannot call method 'removeClass' of undefined