Show loader for mod update

This commit is contained in:
Björn Dahlgren 2014-05-29 21:45:32 +02:00
parent 8b893cb93c
commit 45e3c7f088
2 changed files with 13 additions and 2 deletions

View File

@ -6,6 +6,7 @@ define(function (require) {
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
Ladda = require('ladda'),
tpl = require('text!tpl/mods/list_item.html'),
template = _.template(tpl);
@ -21,13 +22,23 @@ define(function (require) {
update: function (event) {
var self = this;
event.preventDefault();
this.laddaBtn = Ladda.create(this.$el.find(".ladda-button").get(0));
this.laddaBtn.start();
this.$el.find('.ladda-button').addClass('disabled');
$.ajax({
url: "/api/mods/" + this.model.get('name'),
type: 'PUT',
success: function (resp) {
self.laddaBtn.stop();
self.$el.find('.ladda-button').removeClass('disabled');
self.trigger("mods:update", mods);
},
error: $.noop
error: function (resp) {
self.laddaBtn.stop();
self.$el.find('.ladda-button').removeClass('disabled');
},
});
},
});

View File

@ -1,7 +1,7 @@
<td>
<a href='#mods/<%-name%>'><%-name%></a>
<% if (outdated) { %>
<a class="btn btn-primary btn-xs update pull-right">
<a class="btn btn-primary btn-xs update pull-right ladda-button" data-style="expand-left">
<span class="glyphicon glyphicon-save"></span>
Update
</a>