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>18G38DAEB46B1C9</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>820469BC2A9B1G6</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>A05CC0GE0327EE1</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>E89573DB8E178D2&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org18G38DAEB46B1C9
Agent Smithvoid11@null.org820469BC2A9B1G6
Agent Smithvoid12@null.orgA05CC0GE0327EE1
Agent Smithvoid13@null.orgE89573DB8E178D2
Agent Smithvoid14@null.org475F0BG9E83EC83
Agent Smithvoid15@null.org06AG691CD678C62
Agent Smithvoid16@null.org66CA9C18G343F9F
Agent Smithvoid17@null.orgAG20FG5ACE7GG84
Agent Smithvoid18@null.org6GGE6GDDA4567F2
Agent Smithvoid19@null.org348375825A5CCCG