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 primary' hx-get="/contacts/?page=2"
hx-target="#replaceMe"
hx-swap="outerHTML">
Load More Agents... <img class="htmx-indicator" src="/img/bars.svg" alt="">
</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.
<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>C30E3B05B864C40</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>DG1191AFC0E40FF</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>15336G01541D363</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>6230818FF7070A4&...| Name | ID | |
|---|---|---|
| Agent Smith | void10@null.org | C30E3B05B864C40 |
| Agent Smith | void11@null.org | DG1191AFC0E40FF |
| Agent Smith | void12@null.org | 15336G01541D363 |
| Agent Smith | void13@null.org | 6230818FF7070A4 |
| Agent Smith | void14@null.org | 878E5922389G483 |
| Agent Smith | void15@null.org | 7071502G7FD1A38 |
| Agent Smith | void16@null.org | DFC931D7D6F42C0 |
| Agent Smith | void17@null.org | 881GGEAD1973D73 |
| Agent Smith | void18@null.org | 3E5A133B4405DA7 |
| Agent Smith | void19@null.org | ACGG04F84581926 |
|
|
||