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>6F62B4504108392</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>8462F39E350B08C</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>G47021531D2G33B</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>BD02GFC0B3BG55F&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org6F62B4504108392
Agent Smithvoid11@null.org8462F39E350B08C
Agent Smithvoid12@null.orgG47021531D2G33B
Agent Smithvoid13@null.orgBD02GFC0B3BG55F
Agent Smithvoid14@null.orgGDG3BEAFA5F85C1
Agent Smithvoid15@null.org61G2DA4637C76G6
Agent Smithvoid16@null.orgB59B73681E21549
Agent Smithvoid17@null.org35EF1A1B92F46C8
Agent Smithvoid18@null.orgED40DG88EA41388
Agent Smithvoid19@null.orgAE2BG503496EDG9