Skip to content

Commit

Permalink
Change button state before event process
Browse files Browse the repository at this point in the history
  • Loading branch information
hitaishi19 committed Dec 3, 2024
1 parent ee22a35 commit d00f454
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions client/src/legacy/LeftAndMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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($(
Expand Down Expand Up @@ -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;
},
Expand Down

0 comments on commit d00f454

Please sign in to comment.