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>ECDE9B7FG952112</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>B5CC82F39DG1192</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>CEF0BF9550707G6</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>65CE8G20CB6A0B1&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.orgECDE9B7FG952112
Agent Smithvoid11@null.orgB5CC82F39DG1192
Agent Smithvoid12@null.orgCEF0BF9550707G6
Agent Smithvoid13@null.org65CE8G20CB6A0B1
Agent Smithvoid14@null.orgAE35E1E94ED5150
Agent Smithvoid15@null.orgBED6B6AC1475363
Agent Smithvoid16@null.org1119592B76C522A
Agent Smithvoid17@null.org48330D759FFFEA7
Agent Smithvoid18@null.org6B6G037F54GC7EF
Agent Smithvoid19@null.orgE1A7G9263ABACA1