htmx/www/examples/infinite-scroll.md
carson ef64f8fcf8 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	www/examples/infinite-scroll.md
2020-05-17 06:01:23 -07:00

2.7 KiB

layout
demo_layout.njk

Htmx Pattern: Infinite scroll

The infinite scroll pattern provides a way to load content dynamically on user scrolling action.

Let's focus on the final row (or the last element of your content):

<tr hx-get="/contacts/?page=2"
    hx-trigger="revealed"
    hx-swap="afterend">
  <td>Agent Smith</td>
  <td>void29@null.org</td>
  <td>55F49448C0</td>
</tr>

This last element contains a listener which, when scrolled into view, will trigger a request. The result is then appended after it. The last element of the results will itself contain the listener to load the next page of results, and so on.

{% include demo_ui.html.liquid %}