feature: Pagination complete and functional

This commit is contained in:
Keith Solomon
2025-02-12 12:56:00 -06:00
parent 4cea0703c2
commit 2e5354c97e
3 changed files with 35 additions and 18 deletions

View File

@@ -75,8 +75,14 @@ jQuery(document).ready(function ($) {
$('#result-count').text(response.count);
// Update pagination
if (response.pagination) {
if (response.pagination && response.pagination.length > 0) {
// Clear and update pagination container
if (!$('.pagination').length) {
$('#resource-results').after('<div class="pagination"></div>');
}
$('.pagination').html(response.pagination.join(''));
} else {
$('.pagination').html(''); // Clear pagination if no links are needed
}
});
}
@@ -120,6 +126,19 @@ jQuery(document).ready(function ($) {
$('#sort-order').on('change', function () {
triggerFiltering();
});
// Handle pagination click
$(document).on('click', '.pagination a', function (e) {
e.preventDefault();
// Extract the page number from the link
let pagedMatch = $(this).attr('href').match(/paged=(\d+)/);
let paged = pagedMatch ? pagedMatch[1] : 1; // Default to page 1 if no match is found
// Trigger filtering for the selected page
triggerFiltering(paged);
});
});
document.addEventListener('DOMContentLoaded', function () {
@@ -148,15 +167,4 @@ document.addEventListener('DOMContentLoaded', function () {
});
}
});
// Handle pagination click
$(document).on('click', '.pagination a', function (e) {
e.preventDefault();
// Extract the page number from the link
let paged = $(this).attr('href').match(/paged=(\d+)/)[1];
// Trigger filtering for the selected page
triggerFiltering(paged);
});
});

View File

@@ -130,6 +130,13 @@
margin-top: 20px;
}
.pagination ul {
list-style: none;
display: flex;
gap: 8px;
padding: 0;
}
.pagination a,
.pagination span {
margin: 0 5px;