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>BG0FCF837C10E95</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>A50297FF444BE01</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>D8653869E0DA4AD</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>E5B7B8ACBC79889&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.orgBG0FCF837C10E95
Agent Smithvoid11@null.orgA50297FF444BE01
Agent Smithvoid12@null.orgD8653869E0DA4AD
Agent Smithvoid13@null.orgE5B7B8ACBC79889
Agent Smithvoid14@null.orgBE82030197A5093
Agent Smithvoid15@null.org4BEDA856C474C55
Agent Smithvoid16@null.orgE6C6B6BB6B0BD06
Agent Smithvoid17@null.orgGB1G953BFE7DD44
Agent Smithvoid18@null.org71G369BCAG79GEC
Agent Smithvoid19@null.org32C806FAE47F36D