Working on a slower, proprietary ecommerce platform and the client has requested that the call-to-action buttons on the site switch to spinner or loading animations after being clicked to reduce repeated submissions/clicks by the user. There is currently a good bit of delay between frontend interaction and backend results.
Almost all of the buttons are already bound to Javascript events to power their functionality. The loader animation is readily achievable by appending a new CSS class entitled "loading" to the button element.
HTML Button Example:
<button class="mz-button ui primary button" data-mz-action="next">Next</button>
HTML Button Example with Loading Animation:
<button class="mz-button ui primary button loading" data-mz-action="next">Next</button>
I think its best to avoid modifying the pre-existing Javascript methods/functions directly but what would be a "best practice" approach to append the "loading" class on button click but also ensure that the default button behavior is unaffected? From what I can tell, it seems that making use of this for specific button selection within the DOM might be smart.
As a secondary objective, it would be great if I could have this happen for any button site-wide.