Closed jens closed 3 years ago
One disadvantage with using "show:top" is that all anchor links breaks. Instead of going to the anchor it will go to the top of the page.
Thank you for contributing!
Hi there,
This is a nice default option but I see no way to get the original behavior back: what if I want no scrolling at all?
Okay there is a (not perfect) solution: appending a #
to the link URL. I think show:noop
would be preferable, what do you think?
agree
looking at the code, it looks like
hx-swap="show:unset"
should work. I will document this as a supported option.
With v1.4.1, show:unset
doesn't work. I've seen a discussion here about some unset
behavior that would be similar, but unmerged yet.
I found this issue while trying to look if there was a bug report on the scrolling to top. I think this idea was merged without thinking through the consequences fully. If you want it to scroll to the top, why not just use a normal link instead of boost?
The idea is to have boosted links behave as much like "normal" links as possible, and normal links scroll to the top. If you want custom scrolling behavior, you can use a hx-get
pretty easily.
Possible to disable the smooth scrolling behaviour?
This bit me today as I was getting started with HTMX for the first time. I was trying to make inline editing on a large table avoid reloading the whole page by adding hx-boost="true"
to the form. It works perfectly except for the fact that it scrolls to the top, which loses the context on the page, which is what I was trying to avoid by adopting HTMX in the first place! Adding hx-swap="show:unset"
didn't help for me either.
I suppose the "correct" hypermedia approach would be to add an endpoint that allows me to swap out only the row in question when it is changed, but I was hoping that hx-boost
would provide a low-effort, high-value way of getting started with HTMX. Is there any possibility of making this configurable, even with hx-swap
as suggested previously?
You have to use hx-swap="innerHTML show:unset"
because without specifying the swap style innerHTML
, outerHTML
etc. the modifiers are not taken into account. You can actually use any keyword after show
except top
and bottom
.
When a link is boosted it would be nice to automatically be at the top of the page as one would be if it was a non boosted link. Currently the scroll position will be the same as it was on the page before navigating.
It is easy to configure with hx-swap="innerHTML show:top" but should probably be the default behaviour.