arma-server-web-admin/public/js/app/views/missions/upload.js

37 lines
788 B
JavaScript
Raw Normal View History

var $ = require('jquery')
var _ = require('underscore')
var Marionette = require('marionette')
var Ladda = require('ladda')
2014-04-06 23:01:34 +00:00
var tpl = require('tpl/missions/upload.html')
2014-04-06 23:01:34 +00:00
module.exports = Marionette.ItemView.extend({
template: _.template(tpl),
2014-04-06 23:01:34 +00:00
events: {
'click form button': 'submit'
},
2014-04-06 23:01:34 +00:00
submit: function (event) {
event.preventDefault()
var self = this
var $form = this.$el.find('form')
2014-07-26 09:01:53 +00:00
var $uploadBtn = $form.find('button[type=submit]')
var laddaBtn = Ladda.create($uploadBtn.get(0))
laddaBtn.start()
2014-04-06 23:01:34 +00:00
$.ajax('/api/missions', {
success: function (data) {
laddaBtn.stop()
self.render()
},
error: function () {
laddaBtn.stop()
},
files: $form.find(':file'),
iframe: true
})
}
})