From 4b7135a3e909b655375da8697965d2046c493f18 Mon Sep 17 00:00:00 2001 From: Jim Bumgardner Date: Tue, 20 Aug 2024 10:20:10 -0700 Subject: [PATCH] Simplified paging rendering logic. --- src/js/cagov-paginator.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/cagov-paginator.js b/src/js/cagov-paginator.js index 94f9a437..fa0f6f7c 100644 --- a/src/js/cagov-paginator.js +++ b/src/js/cagov-paginator.js @@ -68,12 +68,16 @@ class CAGovPaginator extends HTMLElement { drawCurrentPage() { console.log("drawCurrentPage",this.currentPage); - this.pagedContainer.innerHTML = ""; + this.pagedBlocks.forEach((block,index) => { + var displayStyle = "none"; if (index >= (this.currentPage - 1) * this.perPage && index < this.currentPage * this.perPage) { - this.pagedContainer.appendChild(block); + displayStyle = "block"; } + block.style.display = displayStyle; }); + + location.hash = `#page-${this.currentPage}`; // console.log("location.hash",location.hash); }