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>FCABA0A11C5E4AF</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>72AC82EFED1E1DF</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>2FD1582DA81EG5D</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>D6D7AC5A0416382&...
Name | ID | |
---|---|---|
Agent Smith | void10@null.org | FCABA0A11C5E4AF |
Agent Smith | void11@null.org | 72AC82EFED1E1DF |
Agent Smith | void12@null.org | 2FD1582DA81EG5D |
Agent Smith | void13@null.org | D6D7AC5A0416382 |
Agent Smith | void14@null.org | 1DCG6806A09G1AB |
Agent Smith | void15@null.org | 74AF3FE1DF32252 |
Agent Smith | void16@null.org | 94627G6G612C0C9 |
Agent Smith | void17@null.org | 5B71C313C645ADC |
Agent Smith | void18@null.org | DC93D95F1EBA818 |
Agent Smith | void19@null.org | 904A59824D7E9B1 |
|