Pagination et databag
In this example the built-in pagination component in used with a databag.
When using the Jaxon\App\PageDatabagTrait trait, the current page number is saved in a user defined databag.
The component will show this page when it is re-rendered, instead of going back to the first page.
Note: the
Refreshbutton actually re-renders the component. But since the same page number is displayed, it seems like nothing has changed.
The HTML code.
<div class="row">
<!-- Custom attribute: Component for paginated content. -->
<div class="col-md-12" <?= attr()->bind(rq(PageContentDb::class)) ?>>
</div>
<!-- Custom attribute: Component for pagination links. -->
<div class="col-md-12" <?= attr()->pagination(rq(PageContentDb::class)) ?>>
</div>
<div class="col-md-12 buttons">
<button type="button" class="btn btn-primary" <?= attr()
->click(rq(PageContentDb::class)->show()) ?>>Refresh</button>
</div>
</div>
The exported class
The Jaxon library config
The Jaxon setup code.
<?php
jaxon()->app()->setup(configFile('pagination.php'));
The Javascript code is generated from this PHP template.
jaxon.dom.ready(() => {
<?= rq(PageContentDb::class)->show() ?>;
});