diff --git a/public/js/app/views/mods/form.js b/public/js/app/views/mods/form.js index 0dadcb7..bc3db95 100644 --- a/public/js/app/views/mods/form.js +++ b/public/js/app/views/mods/form.js @@ -12,6 +12,11 @@ define(function (require) { tpl = require('text!tpl/mods/form.html'); return Marionette.ItemView.extend({ + + events: { + 'submit': 'beforeSubmit', + }, + template: _.template(tpl), initialize: function (options) { @@ -21,6 +26,11 @@ define(function (require) { this.bind('shown', this.shown); }, + beforeSubmit: function(e) { + e.preventDefault(); + this.submit(); + }, + shown: function (modal) { var $okBtn = modal.$el.find('.btn.ok'); $okBtn.addClass('ladda-button').attr('data-style', 'expand-left'); @@ -32,20 +42,22 @@ define(function (require) { var self = this; var $form = $('form'); - modal.preventClose(); + if (modal) { + self.modal.preventClose(); + } $form.find('.form-group').removeClass('has-error'); $form.find('.help-block').text(''); this.laddaBtn.start(); - modal.$el.find('.btn.cancel').addClass('disabled'); + self.modal.$el.find('.btn.cancel').addClass('disabled'); this.model.save({ name: $form.find('.mod').val() }, { success: function () { self.mods.fetch({ success : function () { self.laddaBtn.stop(); - modal.close(); + self.modal.close(); } }); }, @@ -53,7 +65,7 @@ define(function (require) { self.laddaBtn.stop(); $form.find('.form-group').addClass('has-error'); $form.find('.help-block').text('Problem downloading mod'); - modal.$el.find('.btn.cancel').removeClass('disabled'); + self.modal.$el.find('.btn.cancel').removeClass('disabled'); } }); }, diff --git a/public/js/app/views/mods/list.js b/public/js/app/views/mods/list.js index 0e89c6a..774c31f 100644 --- a/public/js/app/views/mods/list.js +++ b/public/js/app/views/mods/list.js @@ -32,7 +32,9 @@ define(function (require) { download: function (event) { event.preventDefault(); var view = new FormView({mods: this.collection}); - new Backbone.BootstrapModal({ content: view, animate: true }).open(); + var modal = new Backbone.BootstrapModal({ content: view, animate: true }); + view.modal = modal; + modal.open(); }, }); }); diff --git a/public/js/tpl/mods/form.html b/public/js/tpl/mods/form.html index c8c53b5..8fbac35 100644 --- a/public/js/tpl/mods/form.html +++ b/public/js/tpl/mods/form.html @@ -3,10 +3,10 @@ such as @A3MP
-