javascript - backbone.js - how and when to show a spinner -


is there sort of hooks in backbone can "whenever of collections fetching data, show spinner, hide when they're done"?

i have feeling more complicated , require overwriting specific functions. when should show spinner? on fetch() or refresh() or else?

backbone doesn't trigger event when collection::fetch() starts (see source code), have override fetch method. maybe this:

var oldcollectionfetch = backbone.collection.prototype.fetch;  backbone.collection.prototype.fetch = function(options) {     this.trigger("fetch:started");     oldcollectionfetch.call(this, options); } 

this override fetch method give event when fetch starts. however, triggers event on specific collection instance if have bunch of different collections you'll have listen event on each collection.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -