Trigger other elements
See original GitHub issueHi everybody, a little bit of a background from my side: I worked at a company where we build a similar framework like htmx for internal usage. So I was excited to see the very same idea in the wild last year. Then I decided to use htmx for a small side-project of mine.
Looking at https://htmx.org/examples/ and sifting through the reference however it became clear that there was one important use-case not obviously being covered (or I’m didn’t find it in the docs). Think of the following situation in pseudo-html:
<html>
<body>
<stuff>
<list of things>
<other stuff>
<create-form>
<yet other stuff>
When the create-form successfully created a new object, the list of things should be updated as well as the create-form being reset for yet another post. And the rest of the stuff, body or html should not be touched or triggered.
This brings me to the proposal:
Reloading multiple others hx-elements by triggering them.
Or alternatively:
Let’s add an example for a create-form with updating other elements after successful form submission (if that’s already possible).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:14 (13 by maintainers)

Top Related StackOverflow Question
The preferred way of doing this would be to use the htmx events, either with vanilla javascript or hyperscript.
Here’s what the hyperscript would look like:
@ribeiropaulor Custom events sound really cool. I don’t know if
hx-targetis really necessary buthx-dispatch-after-swapseem to do the trick here.@1cg What is your opinion on this?