htmx/www/examples/infinite-scroll.md

2.7 KiB

layout
demo_layout.njk

Kutty 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:

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

This row (or the last element of your content) 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 %}