我有一個Backbone應用程序,我可以通過單擊列表中的一個Letter來獲取不同的集合。所以,我想添加一個Progressbar或某種旋轉圖像,但我不知道如何做到這一點。BackboneJS - 如何在獲取集合時添加一個Progressbar
我的視圖看起來像這樣
function (App, Backbone) {
var Artists = App.module();
var ArtistView = Backbone.View.extend({
tagName : 'li',
template: 'artistItem',
serialize: function() {
var data = this.model.toJSON();
data.letter = this.model.collection.letter;
return data;
},
});
Artists.View = Backbone.View.extend({
tagName : 'ul',
className : 'artistList',
initialize: function() {
this.listenTo(this.collection, 'all', this.render);
this.listenTo(App, 'navigateLetter', this.updateState);
},
beforeRender: function() {
var self = this;
this.collection.each(function(item) {
self.insertView(new ArtistView({model: item}))
})
},
updateState: function(letter) {
this.collection.letter = letter;
this.stopListening(this.collection);
this.collection.fetch();
this.listenTo(this.collection, 'all', this.render);
}
});
Artists.ArtistsCollection = Backbone.Collection.extend({
url: function() {
return '/projects/mdk/index.php/api/artists/' + this.letter;
}
});
return Artists;
});
因此,沒有人有一個想法如何做到這一點?我可以想象我應該在initialize或beforeRender中做些什麼?
在此先感謝