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>BCEA7A7CF2789E0</td></tr>
<tr><td>Agent Smith</td><td>void21@null.org</td><td>DF9815C7D03GDF2</td></tr>
<tr><td>Agent Smith</td><td>void22@null.org</td><td>FD20612975B2D4D</td></tr>
<tr><td>Agent Smith</td><td>void23@null.org</td><td>43511E515D6G3G0</td></tr>
<tr><td>Agent Smith</...
| Name | ID | |
|---|---|---|
| Agent Smith | void10@null.org | 18BB1BC219G1C58 |
| Agent Smith | void11@null.org | 5AFG0F8057C6601 |
| Agent Smith | void12@null.org | 6A7814E3628CAD8 |
| Agent Smith | void13@null.org | C01CFCFD4789467 |
| Agent Smith | void14@null.org | AA159C281GA903G |
| Agent Smith | void15@null.org | 057GFE52F66BCE6 |
| Agent Smith | void16@null.org | A71AA39C4B2D1E8 |
| Agent Smith | void17@null.org | 93BFB9G052E1G80 |
| Agent Smith | void18@null.org | AEB3B4999FE5714 |
| Agent Smith | void19@null.org | 7E59FBE42B6079E |
| Agent Smith | void20@null.org | BCEA7A7CF2789E0 |
| Agent Smith | void21@null.org | DF9815C7D03GDF2 |
| Agent Smith | void22@null.org | FD20612975B2D4D |
| Agent Smith | void23@null.org | 43511E515D6G3G0 |
| Agent Smith | void24@null.org | 81C1F49AFDD29DC |
| Agent Smith | void25@null.org | 3F76F5FFG3CA6B3 |
| Agent Smith | void26@null.org | EBE6295EGBF8668 |
| Agent Smith | void27@null.org | 99625400E497DB9 |
| Agent Smith | void28@null.org | 947B3AFAD1AFCBE |
| Agent Smith | void29@null.org | 13B65FB642E06E6 |
|
|
||