LiveView tracks things by DOM ID. So as long you make the container with phx-update=“prepend” have a different DOM ID whenever the page changes, for example by append the current page to the DOM ID, then everything will work:
- whenever the page changes, you start with a fresh container
- you can still prepend to the container
However, I think that pagination is most likely a poor fit for something that also receives updates live. If you are on page 2 and there is new content, what do you do?
Maybe a better fit is this:
- you have two containers (one for prepending and another for appending)
- LV updates go to the prepend container
- You have a button at the bottom that says “load more”. whenever you click “load more”, you append new entries to the append container
Of coruse, there are UI/UX considerations here that are outside of using LV or not, but whatever approach you choose should be doable!