mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
37 lines
788 B
JavaScript
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
|
|
})
|
|
}
|
|
})
|