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

41 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'),
FormView = require('marionette-formview'),
IframeTransport = require('jquery.iframe-transport'),
Mission = require('app/models/mission'),
2014-04-06 23:01:34 +00:00
tpl = require('text!tpl/missions/form.html');
2014-04-05 14:50:40 +00:00
return Marionette.ItemView.extend({
template: _.template(tpl),
2014-04-06 23:01:34 +00:00
2014-04-05 14:50:40 +00:00
initialize: function (options) {
this.missions = options.missions;
this.model = new Mission();
this.bind("ok", this.submit);
},
2014-04-06 23:01:34 +00:00
2014-04-05 14:50:40 +00:00
submit: function (modal) {
var self = this;
2014-04-06 23:01:34 +00:00
2014-04-05 14:50:40 +00:00
modal.preventClose();
2014-04-06 23:01:34 +00:00
2014-04-05 14:50:40 +00:00
var $form = $("form");
$.ajax("/api/missions", {
files: $form.find(":file"),
iframe: true
}).complete(function(data) {
modal.close();
2014-04-06 23:01:34 +00:00
self.missions.fetch({success : function () {
Backbone.history.navigate('#missions', true);
}});
2014-04-05 14:50:40 +00:00
});
},
});
2014-04-06 23:01:34 +00:00
});