The Center for Education Reform is innovating a dynamic new web experience - check back often to explore the latest updates!

document.addEventListener("DOMContentLoaded", function () { function enableAjaxPagination() { console.log("AJAX Pagination script loaded"); // Debugging log document.querySelectorAll(".bricks-pagination a").forEach(link => { if (!link.dataset.ajaxBound) { // Prevent multiple event bindings link.dataset.ajaxBound = "true"; link.addEventListener("click", function (event) { event.preventDefault(); // Stop full page reload console.log("Pagination link clicked:", this.href); let url = this.href; fetch(url, { method: "GET" }) .then(response => response.text()) .then(html => { let parser = new DOMParser(); let doc = parser.parseFromString(html, "text/html"); let newPosts = doc.querySelector("#brxe-unssnw"); let oldPosts = document.querySelector("#brxe-unssnw"); if (newPosts && oldPosts) { console.log("Updating posts..."); oldPosts.innerHTML = newPosts.innerHTML; // Update the pagination links let newPagination = doc.querySelector(".bricks-pagination"); let oldPagination = document.querySelector(".bricks-pagination"); if (newPagination && oldPagination) { oldPagination.innerHTML = newPagination.innerHTML; } // Push new URL to browser history window.history.pushState({}, "", url); // Scroll smoothly to the posts section window.scrollTo({ top: oldPosts.offsetTop, behavior: "smooth" }); // Reinitialize event listeners enableAjaxPagination(); } else { console.error("Posts container not found"); } }) .catch(error => console.error("AJAX Error:", error)); }); } }); } enableAjaxPagination(); // Initialize });