2019-09-22 21:02:31 +00:00
|
|
|
var $ = require('jquery')
|
|
|
|
var _ = require('underscore')
|
|
|
|
var Marionette = require('marionette')
|
|
|
|
var Ladda = require('ladda')
|
2014-04-06 23:01:34 +00:00
|
|
|
|
2019-09-22 21:02:31 +00:00
|
|
|
var tpl = require('tpl/missions/upload.html')
|
2014-04-06 23:01:34 +00:00
|
|
|
|
2019-09-22 21:02:31 +00:00
|
|
|
module.exports = Marionette.ItemView.extend({
|
|
|
|
template: _.template(tpl),
|
2014-04-06 23:01:34 +00:00
|
|
|
|
2019-09-22 21:02:31 +00:00
|
|
|
events: {
|
|
|
|
'click form button': 'submit'
|
|
|
|
},
|
2014-04-06 23:01:34 +00:00
|
|
|
|
2020-06-21 10:10:11 +00:00
|
|
|
submit: function (event) {
|
|
|
|
event.preventDefault()
|
2019-09-22 21:02:31 +00:00
|
|
|
var self = this
|
|
|
|
var $form = this.$el.find('form')
|
2014-07-26 09:01:53 +00:00
|
|
|
|
2019-09-22 21:02:31 +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
|
|
|
|
2019-09-22 21:02:31 +00:00
|
|
|
$.ajax('/api/missions', {
|
|
|
|
success: function (data) {
|
|
|
|
laddaBtn.stop()
|
|
|
|
self.render()
|
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
laddaBtn.stop()
|
|
|
|
},
|
|
|
|
files: $form.find(':file'),
|
|
|
|
iframe: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|