Almost have pagination working. On the backend it works but I can't figure out how to make alpine do the request and update.

This commit is contained in:
Zed A. Shaw 2025-07-27 12:43:15 -04:00
parent c8ece708c3
commit 52e92a3814
3 changed files with 32 additions and 22 deletions

View file

@ -1,13 +1,25 @@
<script>
let Tables = new GetJson("/api/admin/table/{{ .Table }}/")
console.log("Tables", Tables)
let page = 0;
let Tables = new GetJson(`/api/admin/table/{{ .Table }}/?page=${page}`);
const newPage = (new_page_num) => {
console.log("the function");
page = new_page_num;
new GetJson(`/api/admin/table/{{ .Table }}/?page=${page}`);
}
</script>
<blockstart>
<h1>Admin Tables</h1>
<h1><a href="/admin/table/">&laquo;</a> Admin {{ .Table }}</h1>
<block x-data="Tables">
<button type="button"><a href="/admin/new/table/{{ .Table }}/">New</a></button>
<block x-data="Tables" x-effect="newPage(page)">
<block class="horizontal">
<button type="button"><a href="/admin/new/table/{{ .Table }}/">New</a></button>
<button type="button" @click="page -= 1">Prev</button>
<button type="button" @click="page += 1">Next</button>
<input type="text" name="search" size="35" placeholder="Search" />
<button type="button">Search</button>
</block>
<table>
<template x-for="item in theData">
<tr>
@ -22,10 +34,6 @@
</tr>
</template>
</table>
<block class="horizontal">
<a href="/admin/table/{{.Table}}/?page=2">Prev</a>
<a href="/admin/table/{{.Table}}/?page=2">Next</a>
</block>
</block>
</blockstart>