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>EDAD9C0FA5730E4</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>2BC9007BC4E613D</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>F1275867CE708F6</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>D9274G167750021&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.orgEDAD9C0FA5730E4
Agent Smithvoid11@null.org2BC9007BC4E613D
Agent Smithvoid12@null.orgF1275867CE708F6
Agent Smithvoid13@null.orgD9274G167750021
Agent Smithvoid14@null.orgCDD80F2CCE7F5F5
Agent Smithvoid15@null.org22FG12F0F4EBAF2
Agent Smithvoid16@null.org314B13GC2634BCB
Agent Smithvoid17@null.org4EBA6FF3254546D
Agent Smithvoid18@null.orgB5C4G7987804412
Agent Smithvoid19@null.orgAEG095G831546D9