});
$('#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>