add img pagination support of infinite scroll

This commit is contained in:
Noémi Ványi 2016-12-28 12:39:20 +01:00
parent 2ec6034c85
commit 420ef433ae

View File

@ -4,9 +4,13 @@ $(document).ready(function() {
if ($(document).height() - win.height() == win.scrollTop()) { if ($(document).height() - win.height() == win.scrollTop()) {
var formData = $('#pagination form:last').serialize(); var formData = $('#pagination form:last').serialize();
if (formData) { if (formData) {
var pageno = $('#pagination input[name=pageno]:last').attr('value');
$('#pagination').html('<div class="loading-spinner"></div>'); $('#pagination').html('<div class="loading-spinner"></div>');
$.post('./', formData, function (data) { $.post('./', formData, function (data) {
var lastImageHref = $('.result-images:last a').attr('href');
var body = $(data); var body = $(data);
$('a[href^="#open-modal"]:last').attr('href', '#open-modal-1-' + pageno);
body.find('.modal-image a:first').attr('href', lastImageHref);
$('#pagination').remove(); $('#pagination').remove();
$('#main_results').append('<hr/>'); $('#main_results').append('<hr/>');
$('#main_results').append(body.find('.result')); $('#main_results').append(body.find('.result'));