fix saving template from job submission form
[qcg-portal.git] / qcg / templates / qcg / job_submit.html
index 560bd99..87b8a2c 100644 (file)
             });
 
             $('#template').on('show.bs.modal', function() {
-                $(this).find('.alert').remove();
                 this.reset();
             }).on('shown.bs.modal', function() {
                 $(this).find('input[type="text"]')[0].focus();
             }).on('submit', function(e) {
                 e.preventDefault();
 
-                var $this = $(this),
-                    $btn = $this.find('[type="submit"]');
-
-                $this.find('.alert-danger').remove();
-                $btn.button('loading');
-
-                $.post(this.action, $('#description,#template').serializeArray(), function(response) {
-                    // FIXME url after redirection
-                    document.open();
-                    document.write(response);
-                    document.close();
-                }).fail(function(xhr) {
-                    var error = (xhr.responseJSON || {}).error || 'Błąd serwera';
-
-                    $('<div>', {
-                        'class': 'alert alert-danger',
-                        html: '<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> ' + error
-                    }).prependTo($this.find('.modal-body'));
-
-                    $btn.button('reset');
-                });
+                // copy this form's fields to description form and send it
+                $('#description').append($(this).find('input').clone().attr('type', 'hidden')).submit();
             });
         });
     </script>