Ergonomics when always serving full-page responses
See original GitHub issueOne of the differences between htmx/intercooler and unpoly is that unpoly by default assumes that the backend is serving full pages in responses rather than page fragments. As I am using htmx to enhance a site that should otherwise be perfectly functional without JS, the backend always serves full pages and never partial templates.
Additionally, I’m not sure what your typical sites look like, but I find that I almost never want to swap the element that is being clicked but rather some other element (this is also made easier by the fact that the entire page is served up by the backend, so things like buttons that have text that needs to be changed depending on the context are usually swapped out altogether with the element that is being affected by simply swapping a parent of the button and the results). As a result, all my htmx usages end up extremely verbose and redundant (especially because of #23 and #24), e.g. to simply swap a single element when a checkbox is altered:
<label><input type="checkbox" name="hideIncomplete" hx-get="/Registrations" hx-push="true" hx-target=".registrations" hx-swap="outerHTML" hx-select=".registrations" /> Hide incomplete registrations</label>
I wonder if there’s a configuration option that could be added or else an alternate syntax that could be used that would bundle all this in one to reduce the boilerplate (and chance for error).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:17 (14 by maintainers)
I’m warming up to the idea that in the absence of an explicit target and swap,
hx-select
should define the target as the same item and the swap asouterHTML
.I am not quire sure what this ticket is about but I am just writing to send a big kudos to
hx-select
since I simply convert my links fromto avoid the complete reload of my webpage, without the need to change anything in the backend!.
I cannot remember if this could be done in
intercooler.js
but I am really happy to usehtmx
now.