diff --git a/client/src/legacy/LeftAndMain.js b/client/src/legacy/LeftAndMain.js index a1565fcb0..cf7fe9bc1 100644 --- a/client/src/legacy/LeftAndMain.js +++ b/client/src/legacy/LeftAndMain.js @@ -459,6 +459,10 @@ $.entwine('ss', function($) { if(!button) button = this.find('.btn-toolbar :submit[name=action_save]'); // default to first button if none given - simulates browser behaviour if(!button) button = this.find('.btn-toolbar :submit:first'); + + // set button to "submitting" state + $(button).addClass('btn--loading loading'); + $(button).prop('disabled', true); var beforeSubmitFormEventData = { // array of promises that must resolve({success:true}) before the form is submitted @@ -504,10 +508,6 @@ $.entwine('ss', function($) { self.trigger('submitform', {form: form, button: button}); - // set button to "submitting" state - $(button).addClass('btn--loading loading'); - $(button).prop('disabled', true); - if($(button).is('button')) { $(button).append($( @@ -572,7 +572,10 @@ $.entwine('ss', function($) { newContentEls.filter('form').trigger('aftersubmitform', {status: status, xhr: xhr, formData: formData}); } }, ajaxOptions)); - }); + }).catch(function() { + // Handle errors from the promises + clearButton(); + });; return false; },