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>A2C8444G7DG2FED</td></tr>
<tr><td>Agent Smith</td><td>void11@null.org</td><td>G21ABE2F4EG78F4</td></tr>
<tr><td>Agent Smith</td><td>void12@null.org</td><td>8D444994C0234DG</td></tr>
<tr><td>Agent Smith</td><td>void13@null.org</td><td>A7BBBAEA123FBA8&...
Name | ID | |
---|---|---|
Agent Smith | void10@null.org | A2C8444G7DG2FED |
Agent Smith | void11@null.org | G21ABE2F4EG78F4 |
Agent Smith | void12@null.org | 8D444994C0234DG |
Agent Smith | void13@null.org | A7BBBAEA123FBA8 |
Agent Smith | void14@null.org | 53BD50C584BE9B1 |
Agent Smith | void15@null.org | 2BD8EB9D8BFGCCD |
Agent Smith | void16@null.org | 1E33A5G30B1G9DD |
Agent Smith | void17@null.org | D0CA2DBG0DCA57F |
Agent Smith | void18@null.org | E3147607D0570D2 |
Agent Smith | void19@null.org | 001F730D20073AD |
|