Pattern to have both href and e.g. hx-post on a link #2483
Replies: 1 comment 2 replies
-
Hey, there's no native way to do exactly what you described but you can probably achieve the same result with existing ways. Having Considering a setup where both endpoints are under your control and within your backend; I would advise trying to batch such requests together, as why make your user wait for an extra roundtrip to the server, if you can handle both within the same request and spare a useless waiting time?
If those 2 ideas don't fit your needs, then I'm afraid you might indeed need some custom JS/hyperscript to handle that as you wish. |
Beta Was this translation helpful? Give feedback.
-
I have a somewhat unusual situation where it would be nice to trigger a
hx-post
in the background when clicking on link that already has ahref
attribute. I'd want thehref
to behave normally - e.g. opening a new page, but still havehx-post
triggered. It could be thathref
would wait untilhx-post
is successful.Is there anything that HTMX offers out of the box or do I have to stick together some JS / hyperscript to make that work?
Beta Was this translation helpful? Give feedback.
All reactions