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 primary' 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>35AACF2A57AAGGB</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>7E31FC39C11CD29</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>0AF2D97C537ADG4</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>CEAEC35ED59782D&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org35AACF2A57AAGGB
Agent Smithvoid11@null.org7E31FC39C11CD29
Agent Smithvoid12@null.org0AF2D97C537ADG4
Agent Smithvoid13@null.orgCEAEC35ED59782D
Agent Smithvoid14@null.orgABD7D761G40F58A
Agent Smithvoid15@null.orgB1DE8F71087F942
Agent Smithvoid16@null.orgFBF46FE615B3ABF
Agent Smithvoid17@null.orgAE29A02E1E948B1
Agent Smithvoid18@null.org6E40562A6A4G297
Agent Smithvoid19@null.orgBGG03AC815973BF