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>76444D06C7302GC</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>EC7319267FGDG65</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>EAAC80738F7839E</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>5232GG806G6CCA5&...
Name | ID | |
---|---|---|
Agent Smith | void10@null.org | 76444D06C7302GC |
Agent Smith | void11@null.org | EC7319267FGDG65 |
Agent Smith | void12@null.org | EAAC80738F7839E |
Agent Smith | void13@null.org | 5232GG806G6CCA5 |
Agent Smith | void14@null.org | FG98FE6F14633CF |
Agent Smith | void15@null.org | 856FDB613365157 |
Agent Smith | void16@null.org | A0EB2DB662C5089 |
Agent Smith | void17@null.org | GB458B6C16D80B9 |
Agent Smith | void18@null.org | C109792G58C3G1A |
Agent Smith | void19@null.org | 369CB2FA4E5G5DE |
|