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>C9C32CA2E87A112</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>19C6DD6623C5655</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>6EG8AAG0B6DE768</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>612FABDBD0D99G8&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.orgC9C32CA2E87A112
Agent Smithvoid11@null.org19C6DD6623C5655
Agent Smithvoid12@null.org6EG8AAG0B6DE768
Agent Smithvoid13@null.org612FABDBD0D99G8
Agent Smithvoid14@null.org9G8G9EAC9GD1A91
Agent Smithvoid15@null.org6B657BDFBAG5980
Agent Smithvoid16@null.org0D77A39D57G3DCF
Agent Smithvoid17@null.orgCDG6BGBC0EB7DG7
Agent Smithvoid18@null.orgD2F82710604CFC2
Agent Smithvoid19@null.orgFCF6985397CCB5A