News for hackers. Stuff that matters.
Re:Htmx Is Composable? by paranoidxprod on Wednesday January 17, 2024 @11:33AM (#39029968)
As mentioned in that comment, there is hx-swap-oob, but there is also the official htmx multi-swap extension that makes this pretty trivial.

https://htmx.org/extensions/multi-swap/

In that example, you'd just send partials for the card and cart elements and they'll both be swapped out.

Re:Htmx Is Composable? by sesm on Wednesday January 17, 2024 @01:33PM (#39031546)
If we continue the cart example, what should HTTP endpoint return in that case?
Re:Htmx Is Composable? by paranoidxprod on Wednesday January 17, 2024 @06:20PM (#39035038)
In this example, the html for the card which looks different and the cart with the updated count could be returned. HTMX will swap both with the appropriate element based on the ids of the elements in the Dom and the elements being returned by the server and this won’t cause a whole page refresh or anything.