Click to Load

This example shows how to implement click-to-load the next page in a table of data. The crux of the demo is the final row:

<tr id="replaceMe">
  <td colspan="3">
    <button class='btn' hx-get="/contacts/?page=2"
                        hx-target="#replaceMe"
                        hx-swap="outerHTML">
         Load More Agents... <img class="htmx-indicator" src="/img/bars.svg">
    </button>
  </td>
</tr>

This row contains a button that will replace the entire row with the next page of results (which will contain a button to load the next page of results). And so on.

Server Requests ↑ Show
HTML
<table><thead><tr><th>Name</th><th>Email</th><th>ID</th></tr></thead><tbody>
                <tr><td>Agent Smith</td><td>void10@null.org</td><td>DC98A71CD7GGF9G</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>96FC8170C9CCD3C</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>6DD76D9D0BG5B5C</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>7E700A6E8931D47&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.orgDC98A71CD7GGF9G
Agent Smithvoid11@null.org96FC8170C9CCD3C
Agent Smithvoid12@null.org6DD76D9D0BG5B5C
Agent Smithvoid13@null.org7E700A6E8931D47
Agent Smithvoid14@null.org016CCD958F868EE
Agent Smithvoid15@null.org3AFD24F7ACFG58G
Agent Smithvoid16@null.org15A20DF8DGGA8DA
Agent Smithvoid17@null.org39C57GF690D318A
Agent Smithvoid18@null.org95B318FA4GC8637
Agent Smithvoid19@null.orgB0CD4AGC8BDB812