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">
    </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>9D09E90490DBG2A</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>GA10B39FD1BAB61</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>G4C0EEECCE05289</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>6BEC723146580D2&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org9D09E90490DBG2A
Agent Smithvoid11@null.orgGA10B39FD1BAB61
Agent Smithvoid12@null.orgG4C0EEECCE05289
Agent Smithvoid13@null.org6BEC723146580D2
Agent Smithvoid14@null.org1615E9830BG239C
Agent Smithvoid15@null.org74G4AGG8ECF213A
Agent Smithvoid16@null.orgB22CC81AA9G1BG0
Agent Smithvoid17@null.org4FF800GE564A06C
Agent Smithvoid18@null.orgCDA2474471FF775
Agent Smithvoid19@null.org0D9EE4C308295BC