-
Notifications
You must be signed in to change notification settings - Fork 323
Needs an extension point for adding loading animation #173
Comments
I was just about to add an issue for this and decided to search first and found it. How are you thinking of doing this? |
+1 |
Just sharing how I added a spinner and some of the pitfalls to this approach. Thought it might help spec'ing this out or for anyone that needs an work-around in the interim. The pitfalls: What I'm doing: fetch: function(options) {
this.trigger('fetch', this, options);
return Backbone.PageableCollection.prototype.fetch.call(this, options);
} In my vent/view, I do the following: collection.on("fetch", function() {
$('#summaryLoading').show().spin();
$('#summary tbody').empty();
$('#graphLoading').show().spin();
$('#chart svg').empty();
}, this); Then I destroy on fetch done: collection.fetch({reset: true}).done(_.bind(function () {
$('#summaryLoading').hide().spin(false);
... For anyone looking for a spinner, I'm using http://fgnass.github.io/spin.js/ with no complaints so far |
I added a spinner without touching anything in backgrid. My spinner appears below the table (next to the pagination links) allowing to continue reading the current page until the ajax response comes back. It uses events triggered by Backbone itself. var Spinner = Backbone.View.extend({
tagName: 'span',
initialize: function (options) {
Backgrid.requireOptions(options, ['collection']);
this.listenTo(this.collection, 'request', this.displaySpinner);
this.listenTo(this.collection, 'sync', this.removeSpinner);
this.listenTo(this.collection, 'error', this.removeSpinner);
},
displaySpinner: function () {
this.$el.empty().append('<i class="icon-spinner icon-spin"></i>');
},
removeSpinner: function () {
this.$el.empty();
}
}); It would be great to have an event allowing to make it work for editable grids as well |
I was able to build it in and fade out the whole grid and show a spinner over it while it's loading... but it would be nice if it was built in instead of custom code. |
You can also consolidate the events for this.listenTo(this.collection, 'sync error', this.removeSpinner) |
@wyuenho is this something you would want as part of the 'core', or is it better suited to be a plugin? (like Paginator and Filter) |
Probably in the core. Just need to replace the tbody before and after fetching. Sent from my iPhone
|
@wyuenho could you take a quick look at my implementation of the "loading indicator" and let me know what you think: morficus@7aa8940 |
Whatever the implementation, please consider that the spinner may not be an animated gif but rather a spinning font, as seen on font-awesome here |
to customize, you can either: 1) in your CSS, overwrite the ".backgrid .loading-indicator" class 2) when creating the table, pass in a property called "laodingIndicatorClass"
No description provided.
The text was updated successfully, but these errors were encountered: