Open JackHerring opened 2 months ago
I don't know if there is a way to make it process multiple classes
You can add custom event listeners via a little javascript
document.body.addEventListener('htmx:beforeRequest', function (evt) {
// custom code to add css classes to indicators
evt.target.classList.add('spinner', 'spinner-right')
});
document.body.addEventListener('htmx:afterRequest', function (evt) {
// custom code to remove css classes from indicators
evt.target.classList.remove('spinner', 'spinner-right')
});
These two events always happen at the same time as htmx adds and removes its its request class normally.
My use case is I want to add a spinner to the initiating button when an
hx-post
occursThe CSS framework I am using does that with TWO extra classes on buttons -
.spinner
AND.spinner-(left|right)
When I set
htmx.config.requestClass
to e.g. 'spinner spinner-right' thus:it explodes:
You cannot combine classes under an umbrella 'super' class in CSS
I can't see a hook to tackle this will a custom extension, either
So I am stuck. Is there a way to do this? All I can do is watch the class changing on the element and add and remove styles manually per the existence of
.htmx-request