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>18G38DAEB46B1C9</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>820469BC2A9B1G6</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>A05CC0GE0327EE1</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>E89573DB8E178D2&...
Name | ID | |
---|---|---|
Agent Smith | void10@null.org | 18G38DAEB46B1C9 |
Agent Smith | void11@null.org | 820469BC2A9B1G6 |
Agent Smith | void12@null.org | A05CC0GE0327EE1 |
Agent Smith | void13@null.org | E89573DB8E178D2 |
Agent Smith | void14@null.org | 475F0BG9E83EC83 |
Agent Smith | void15@null.org | 06AG691CD678C62 |
Agent Smith | void16@null.org | 66CA9C18G343F9F |
Agent Smith | void17@null.org | AG20FG5ACE7GG84 |
Agent Smith | void18@null.org | 6GGE6GDDA4567F2 |
Agent Smith | void19@null.org | 348375825A5CCCG |
|