Am I being stupid or does HTMX not support this very simple use case?
on form submit:
1) clear the target area
2) show a loading indicator
3) trigger an ajax call
4) wait for the ajax call to return
5) hide the loading indicator
6) fill the target area
Ideally I would want the loading indicator IN the target area, but that would make it usable only once. Stupid, but I can live with it...
But what seems not to work is 1). It will show my indicator but not clear the target area.
It seems I have to write additional JS to get that behavior. Well then I can write the thing myself. So much for the promise of not having to write JavaScript for simple things.
#htmx #javascript
Post
@splitbrain with "clear" do you mean "reset the form" or "remove/hide all form elements/content"?
@tante remove all elements/content.
Searchform should remove previous results while loading next results.
@splitbrain I see. Yes, I think that requires custom JS
@tante @splitbrain As I noted in a neighbour post – you can achieve that in htmx via a hx-get “request” to a data url with empty html element targeting the thing you want to clear. Not great and hacky, but it works (I used it for ‘clear’ button once).
But yeah, not what htmx was designed for.