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.
<tr><td>Agent Smith</td><td>void20@null.org</td><td>C84AF12GF68A0B2</td></tr>
<tr><td>Agent Smith</td><td>void21@null.org</td><td>28BF9574E20B20D</td></tr>
<tr><td>Agent Smith</td><td>void22@null.org</td><td>8CE102F7AB14GG3</td></tr>
<tr><td>Agent Smith</td><td>void23@null.org</td><td>347AAC915880AF8</td></tr>
<tr><td>Agent Smith</...
Name | ID | |
---|---|---|
Agent Smith | void10@null.org | AA23600EG65272C |
Agent Smith | void11@null.org | 3CB6F8248154FG1 |
Agent Smith | void12@null.org | 879848A9A669B2D |
Agent Smith | void13@null.org | 90B3808993A3481 |
Agent Smith | void14@null.org | GF4363825BE565G |
Agent Smith | void15@null.org | D2EGCFF05D2GDA1 |
Agent Smith | void16@null.org | GFCD3CBD841GCGA |
Agent Smith | void17@null.org | 1B5C1182EDE19FC |
Agent Smith | void18@null.org | EF0FD8B170B93C8 |
Agent Smith | void19@null.org | 47FDB28213GABB4 |
Agent Smith | void20@null.org | C84AF12GF68A0B2 |
Agent Smith | void21@null.org | 28BF9574E20B20D |
Agent Smith | void22@null.org | 8CE102F7AB14GG3 |
Agent Smith | void23@null.org | 347AAC915880AF8 |
Agent Smith | void24@null.org | B32C896EB7G0F82 |
Agent Smith | void25@null.org | 2AB09D4B3GG81B7 |
Agent Smith | void26@null.org | 58GC2EE6447FG22 |
Agent Smith | void27@null.org | E74630BF60DCE36 |
Agent Smith | void28@null.org | 9F247A4B9EAFEF5 |
Agent Smith | void29@null.org | C029F6FF7F694D7 |
|