Fix problem search pagination

This commit is contained in:
cuom1999 2023-04-02 17:57:32 -05:00
parent 90ea6a7844
commit d36a15d02d

View file

@ -3,6 +3,17 @@
window.has_next_page = {{1 if page_obj.has_next() else 0}}; window.has_next_page = {{1 if page_obj.has_next() else 0}};
window.loading_page = false; window.loading_page = false;
$(function() { $(function() {
function getQueryParams() {
var queryParams = {};
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
queryParams[pair[0]] = decodeURIComponent(pair[1]);
}
return queryParams;
}
$(window).on("scroll", function() { $(window).on("scroll", function() {
if (window.loading_page || !window.has_next_page) return; if (window.loading_page || !window.has_next_page) return;
var distanceFromBottom = $(document).height() - ($(window).scrollTop() + $(window).height()); var distanceFromBottom = $(document).height() - ($(window).scrollTop() + $(window).height());
@ -13,6 +24,8 @@
"page": window.page + 1, "page": window.page + 1,
}; };
params = Object.assign({}, getQueryParams(), params);
$.get("{{feed_content_url}}", params) $.get("{{feed_content_url}}", params)
.done(function(data) { .done(function(data) {
$(".has_next").remove(); $(".has_next").remove();