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>FBDA5G8BDFCAED1</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>G2AEDAC3EA15EG0</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>B54D2E96G09A64F</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>E44CB9FF118E9BG&...

Demo

Name Email ID
Agent Smith void10@null.org FBDA5G8BDFCAED1
Agent Smith void11@null.org G2AEDAC3EA15EG0
Agent Smith void12@null.org B54D2E96G09A64F
Agent Smith void13@null.org E44CB9FF118E9BG
Agent Smith void14@null.org F1459446D1736FG
Agent Smith void15@null.org EC40B8867DC5EBB
Agent Smith void16@null.org E9EC00DEG45FE11
Agent Smith void17@null.org FC8FE184A71BGAA
Agent Smith void18@null.org 6612F36GGG887E2
Agent Smith void19@null.org 9GEF2E9D70782AF