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>B435DBFBDB3E203</td></tr>
<tr><td>Agent Smith</td><td>void21@null.org</td><td>46D60FDGG829G06</td></tr>
<tr><td>Agent Smith</td><td>void22@null.org</td><td>748A77A93401153</td></tr>
<tr><td>Agent Smith</td><td>void23@null.org</td><td>F785BDBBCCEA523</td></tr>
<tr><td>Agent Smith</...

Demo

Name Email ID
Agent Smith void10@null.org CG7D7GD6D2AFE9F
Agent Smith void11@null.org 11E5DG8F18D55A7
Agent Smith void12@null.org DG81B4E81E573C8
Agent Smith void13@null.org FD483517B0G7D38
Agent Smith void14@null.org G613GF132912D86
Agent Smith void15@null.org 6G0A080F1771F71
Agent Smith void16@null.org 4GA4EFCD9BABGE0
Agent Smith void17@null.org 5234AE6C758G27E
Agent Smith void18@null.org 8C3G432A116C132
Agent Smith void19@null.org F8548BEA0E321DB
Agent Smith void20@null.org B435DBFBDB3E203
Agent Smith void21@null.org 46D60FDGG829G06
Agent Smith void22@null.org 748A77A93401153
Agent Smith void23@null.org F785BDBBCCEA523
Agent Smith void24@null.org 727CB95C24C3A76
Agent Smith void25@null.org 70C9D01368BEAA7
Agent Smith void26@null.org B6391E7B4115D61
Agent Smith void27@null.org 3A8A6A4EB976C2F
Agent Smith void28@null.org 6548CC40C741D93
Agent Smith void29@null.org B50C3EEC8A4EFD4