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>FCABA0A11C5E4AF</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>72AC82EFED1E1DF</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>2FD1582DA81EG5D</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>D6D7AC5A0416382&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.orgFCABA0A11C5E4AF
Agent Smithvoid11@null.org72AC82EFED1E1DF
Agent Smithvoid12@null.org2FD1582DA81EG5D
Agent Smithvoid13@null.orgD6D7AC5A0416382
Agent Smithvoid14@null.org1DCG6806A09G1AB
Agent Smithvoid15@null.org74AF3FE1DF32252
Agent Smithvoid16@null.org94627G6G612C0C9
Agent Smithvoid17@null.org5B71C313C645ADC
Agent Smithvoid18@null.orgDC93D95F1EBA818
Agent Smithvoid19@null.org904A59824D7E9B1