4 ms·
Something about this feels really at odds with all the "locality of behavior" virtue the creator/maintainer often promotes.
by betenoire 3y ago
Something about this feels really at odds with all the "locality of behavior" virtue the creator/maintainer often promotes.
- sesm 3y agoYep, and as soon as you need non-local updates, the whole concept of HTML-over-the-wire starts breaking down. I really like this HN comment on this topic: https://news.ycombinator.com/item?id=38081174 https://news.ycombinator.com/item?id=38081174
- paranoidxprod 3y agoAs 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/ 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.
- sesm 3y agoIf we continue the cart example, what should HTTP endpoint return in that case?
- paranoidxprod 3y agoIn 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.