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>55B7C0BB0EG76EE</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>322F97AAAAE45AF</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>BBA1G7F0DB98D40</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>2BGAE3616A4215B&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org55B7C0BB0EG76EE
Agent Smithvoid11@null.org322F97AAAAE45AF
Agent Smithvoid12@null.orgBBA1G7F0DB98D40
Agent Smithvoid13@null.org2BGAE3616A4215B
Agent Smithvoid14@null.orgGG127A7193EAD37
Agent Smithvoid15@null.org2DAA3626D928753
Agent Smithvoid16@null.org71934CAG216592G
Agent Smithvoid17@null.org46A2AECE01050D2
Agent Smithvoid18@null.org6689C05E458G37D
Agent Smithvoid19@null.orgG9CG97A35573CAA