Scroll to top on pagination select after next page data is received

The following code works, but on the live server it scrolls to top way before loading next page data, is there any way to wait for next page data and then scroll?
Filament::registerRenderHook('scripts.end',
fn(): string => new HtmlString('
<script>
document.addEventListener("click", function(e) {
if (e?.target?.closest("nav")?.classList.contains("filament-tables-pagination")){
window.scrollTo({top: 0, behavior: "smooth"});
}
});
</script>
'),
);
Filament::registerRenderHook('scripts.end',
fn(): string => new HtmlString('
<script>
document.addEventListener("click", function(e) {
if (e?.target?.closest("nav")?.classList.contains("filament-tables-pagination")){
window.scrollTo({top: 0, behavior: "smooth"});
}
});
</script>
'),
);
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?