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>90G04G9A47363BE</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>E8982EB6GDDA6DF</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>77D1C10CFF3B231</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>95A9275ED78285C&...

🔗Demo

NameEmailID
Agent Smithvoid10@null.org90G04G9A47363BE
Agent Smithvoid11@null.orgE8982EB6GDDA6DF
Agent Smithvoid12@null.org77D1C10CFF3B231
Agent Smithvoid13@null.org95A9275ED78285C
Agent Smithvoid14@null.org05A5FD4FF611G2C
Agent Smithvoid15@null.org6G9GGD6ED735710
Agent Smithvoid16@null.org8741G1CGDC57977
Agent Smithvoid17@null.orgAE2A53851GC3127
Agent Smithvoid18@null.org8DE8E1F4EA39CD0
Agent Smithvoid19@null.org97G561568304E30