Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Andreas Gohr
Andreas Gohr
@splitbrain@fedi.splitbrain.org  ·  activity timestamp 2 weeks ago

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

  • Copy link
  • Flag this post
  • Block
tante
tante
@tante@tldr.nettime.org replied  ·  activity timestamp 2 weeks ago

@splitbrain with "clear" do you mean "reset the form" or "remove/hide all form elements/content"?

  • Copy link
  • Flag this comment
  • Block
Andreas Gohr
Andreas Gohr
@splitbrain@fedi.splitbrain.org replied  ·  activity timestamp 2 weeks ago

@tante remove all elements/content.

Searchform should remove previous results while loading next results.

  • Copy link
  • Flag this comment
  • Block
tante
tante
@tante@tldr.nettime.org replied  ·  activity timestamp 2 weeks ago

@splitbrain I see. Yes, I think that requires custom JS

  • Copy link
  • Flag this comment
  • Block
silmeth 🇺🇦
silmeth 🇺🇦
@silmeth@mstdn.social replied  ·  activity timestamp 2 weeks ago

@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.

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-beta.35 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct