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.
<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>EDAD9C0FA5730E4</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>2BC9007BC4E613D</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>F1275867CE708F6</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>D9274G167750021&...
Name | ID | |
---|---|---|
Agent Smith | void10@null.org | EDAD9C0FA5730E4 |
Agent Smith | void11@null.org | 2BC9007BC4E613D |
Agent Smith | void12@null.org | F1275867CE708F6 |
Agent Smith | void13@null.org | D9274G167750021 |
Agent Smith | void14@null.org | CDD80F2CCE7F5F5 |
Agent Smith | void15@null.org | 22FG12F0F4EBAF2 |
Agent Smith | void16@null.org | 314B13GC2634BCB |
Agent Smith | void17@null.org | 4EBA6FF3254546D |
Agent Smith | void18@null.org | B5C4G7987804412 |
Agent Smith | void19@null.org | AEG095G831546D9 |
|