-
I have a div being swapped by htmx, triggered by a poll. The div contains log-like messages that should get updated with the latest messages when polled. The problem I have is the contents of the div are scroll-able, and while scrolling through messages, the scroll position is lost when htmx swaps the div. I'm curious if there is a standard way to avoid losing the scroll position on swap. Related discussion #756 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Looking into this a little more, I think the answer is probably to use a different swap method than I'm using, such as |
Beta Was this translation helpful? Give feedback.
Looking into this a little more, I think the answer is probably to use a different swap method than I'm using, such as
afterend
. This way, only elements inside the div are added rather than updating the whole parent div. I'm still interested to hear if htmx has some different magical way of doing this, but I won't hold out for that since the basic capabilities are already there.