Auto Refresh for HTMX fragments
Click Next on the Journal feed and leave that page open. For new articles to appear there, Auto Refresh needs to know which slice of the feed you’re looking at.
Give the list a stable ID
Give the list the ID article-feed. When Next replaces the whole list, return a new element with the same ID. The next time an update arrives, the client can still find the list on the page.
<div id="article-feed">{list_content(destination, rows, signed_in, page)}</div>Choose what the response replaces
Look at the first tag of the fragment your controller returns. If the response includes the target element itself, replace it with outerHTML. If the fragment only contains the children, keep the target in place and use innerHTML.
Refresh the list after a favorite
Try this with two readers. Leave one on a filtered feed and favorite an article as the other. The button uses POST, but the subscription needs the list’s GET with the first reader’s filters. That way their count can change without sending them back to page one. Next replaces that list’s subscription. Removing the list ends it.
See Auto Refresh for the controller setup and typed filters.