arma-server-web-admin/public/js/app/views/missions/upload.js
2020-06-21 12:10:55 +02:00

37 lines
788 B
JavaScript

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