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>A2C8444G7DG2FED</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>G21ABE2F4EG78F4</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>8D444994C0234DG</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>A7BBBAEA123FBA8&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.orgA2C8444G7DG2FED
Agent Smithvoid11@null.orgG21ABE2F4EG78F4
Agent Smithvoid12@null.org8D444994C0234DG
Agent Smithvoid13@null.orgA7BBBAEA123FBA8
Agent Smithvoid14@null.org53BD50C584BE9B1
Agent Smithvoid15@null.org2BD8EB9D8BFGCCD
Agent Smithvoid16@null.org1E33A5G30B1G9DD
Agent Smithvoid17@null.orgD0CA2DBG0DCA57F
Agent Smithvoid18@null.orgE3147607D0570D2
Agent Smithvoid19@null.org001F730D20073AD