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>76444D06C7302GC</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>EC7319267FGDG65</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>EAAC80738F7839E</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>5232GG806G6CCA5&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org76444D06C7302GC
Agent Smithvoid11@null.orgEC7319267FGDG65
Agent Smithvoid12@null.orgEAAC80738F7839E
Agent Smithvoid13@null.org5232GG806G6CCA5
Agent Smithvoid14@null.orgFG98FE6F14633CF
Agent Smithvoid15@null.org856FDB613365157
Agent Smithvoid16@null.orgA0EB2DB662C5089
Agent Smithvoid17@null.orgGB458B6C16D80B9
Agent Smithvoid18@null.orgC109792G58C3G1A
Agent Smithvoid19@null.org369CB2FA4E5G5DE