How to handle change in UUI-pagination
# help-with-umbraco
b
I'm currently rewriting a package to Lit and I'm struggling with adding pagination. The uui-library shows that a change event handler can be added. However, in the event that this event handler uses I cannot find which page I've clicked on, can anyone tell me how I can find out which page in the pagination was clicked?
j
You need to look up the element that was clicked on and read the
current
property.
You can get that from the event
Copy code
const currentPage = (e.target as UUIPaginationElement).current
b
Thanks! That did the trick 🙂
I've got another issue with the pagination. I'm going to add sorting to a table that has pagination. When I sort data it would be nice to programatically tell the pagination to go back to page 1. Is there a way to push the pagination to a certain page?
j
Update the
current
property on the element
If you are using Typescript, you can use Lit's @query decorator to cache the element:
Copy code
@query('uui-pagination', true)
private _paginator?: UUIPaginationElement;

onSort() {
  this._paginator?.current = 1;
}
b
You're a magician! Thanks again
40 Views