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 primary' hx-get="/contacts/?page=2"
                        hx-target="#replaceMe"
                        hx-swap="outerHTML">
         Load More Agents... <img class="htmx-indicator" src="/img/bars.svg" alt="">
    </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>79037A83FDFF877</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>6D03496FE48BGG6</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>CG011838B470968</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>651577EE34E1720&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org79037A83FDFF877
Agent Smithvoid11@null.org6D03496FE48BGG6
Agent Smithvoid12@null.orgCG011838B470968
Agent Smithvoid13@null.org651577EE34E1720
Agent Smithvoid14@null.orgCF7BDDD0074B6DG
Agent Smithvoid15@null.orgEF6B0A1C00964C5
Agent Smithvoid16@null.orgD2B54B99AD4C446
Agent Smithvoid17@null.org0EGAGD083B0B2AB
Agent Smithvoid18@null.org4CF83B436ED1C67
Agent Smithvoid19@null.orgA4A5A5AGFF84AA4