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">
</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>BA77FA2A787DD4F</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>924E1525E9F55EC</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>36FCCDDAFBCAGF9</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>B50715A6BGE5925&...
Name | ID | |
---|---|---|
Agent Smith | void10@null.org | BA77FA2A787DD4F |
Agent Smith | void11@null.org | 924E1525E9F55EC |
Agent Smith | void12@null.org | 36FCCDDAFBCAGF9 |
Agent Smith | void13@null.org | B50715A6BGE5925 |
Agent Smith | void14@null.org | 761G3G95367D9ED |
Agent Smith | void15@null.org | BA4358D99872DD1 |
Agent Smith | void16@null.org | F5690E992DGD919 |
Agent Smith | void17@null.org | 18G6FDE9A37E4FA |
Agent Smith | void18@null.org | FDEEG157D9E3A57 |
Agent Smith | void19@null.org | E7EEFDEGB5C910G |
|