i\'d like to show a progress bar while i update the app with fresh content. I guess the best thing to do would be to do it while calling .fetch on a collection.
The cont
Try this:
var SomeView = Backbone.View.extend({
loadStuff: function(){
var self = this;
someModel.fetch({
xhr: function() {
var xhr = $.ajaxSettings.xhr();
xhr.onprogress = self.handleProgress;
return xhr;
}
});
},
handleProgress: function(evt){
var percentComplete = 0;
if (evt.lengthComputable) {
percentComplete = evt.loaded / evt.total;
}
//console.log(Math.round(percentComplete * 100)+"%");
}
});