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

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-04-05 14:50:40 +00:00
define(function (require) {
2014-04-06 23:01:34 +00:00
2014-04-05 14:50:40 +00:00
"use strict";
2014-04-06 23:01:34 +00:00
2014-04-05 14:50:40 +00:00
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
Ladda = require('ladda'),
2014-04-05 14:50:40 +00:00
IframeTransport = require('jquery.iframe-transport'),
Mission = require('app/models/mission'),
2015-08-15 15:12:50 +00:00
tpl = require('text!tpl/missions/upload.html');
2014-04-06 23:01:34 +00:00
2014-04-05 14:50:40 +00:00
return Marionette.ItemView.extend({
template: _.template(tpl),
2014-04-06 23:01:34 +00:00
2014-07-26 09:01:53 +00:00
events: {
'click form button': 'submit',
},
submit: function () {
2014-04-05 14:50:40 +00:00
var self = this;
2015-08-15 15:12:50 +00:00
var $form = this.$el.find('form');
2014-04-06 23:01:34 +00:00
var $uploadBtn = $form.find('button[type=submit]');
var laddaBtn = Ladda.create($uploadBtn.get(0));
laddaBtn.start();
2014-04-05 14:50:40 +00:00
$.ajax("/api/missions", {
2017-10-06 11:20:06 +00:00
success: function(data) {
2018-08-18 11:04:33 +00:00
laddaBtn.stop();
self.render();
2017-10-06 11:20:06 +00:00
},
error: function () {
laddaBtn.stop();
},
2014-04-05 14:50:40 +00:00
files: $form.find(":file"),
iframe: true
});
},
});
2014-04-06 23:01:34 +00:00
});