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 : 1 ↑ Show
GET /contacts/?page=2
parameters: {"page":"2"}
Response
<tr><td>Agent Smith</td><td>void20@null.org</td><td>83AA0D67C14D72D</td></tr>
<tr><td>Agent Smith</td><td>void21@null.org</td><td>AE8493B97CA3GC6</td></tr>
<tr><td>Agent Smith</td><td>void22@null.org</td><td>7022734G261E035</td></tr>
<tr><td>Agent Smith</td><td>void23@null.org</td><td>3A12DCCDCE9CG5E</td></tr>
<tr><td>Agent Smith</...

Demo

Name Email ID
Agent Smith void10@null.org 1D2GFB436FB2AA4
Agent Smith void11@null.org ADCD9947F2C6E65
Agent Smith void12@null.org G02A317G215F3A3
Agent Smith void13@null.org G444BC86B709D02
Agent Smith void14@null.org D6G65D202967775
Agent Smith void15@null.org 7BG289C7B4E54AC
Agent Smith void16@null.org 07C5F2224B169ED
Agent Smith void17@null.org 8C5C4677G23G58D
Agent Smith void18@null.org 4D14B94D736E33B
Agent Smith void19@null.org FCAC136566D4F27
Agent Smith void20@null.org 83AA0D67C14D72D
Agent Smith void21@null.org AE8493B97CA3GC6
Agent Smith void22@null.org 7022734G261E035
Agent Smith void23@null.org 3A12DCCDCE9CG5E
Agent Smith void24@null.org 193DG1G7CGD188C
Agent Smith void25@null.org 851C8B0963C2G5G
Agent Smith void26@null.org 9F13291823C0FGA
Agent Smith void27@null.org GE483596FE622B0
Agent Smith void28@null.org 63964D6916B79G6
Agent Smith void29@null.org 565D030CCG25122