I am using infinite ajax scroll. It is working as in I can click load more items and this loads the content. However ias should stop at the last page and show 'There are no more posts', instead it still shows the 'load more items' link which when clicked starts the pagination again from page 2.
console:
Welcome at page 2, the original url of this page would be: /website/home/2
Welcome at page 3, the original url of this page would be: /website/home/3
ias should display 'There are no more posts' - instead it continues as below:
Welcome at page 4, the original url of this page would be: /website/home/2
Welcome at page 5, the original url of this page would be: /website/home/3
ias:
<script type="text/javascript">
var ias = $.ias({
container: "#posts",
item: ".post",
pagination: "#pagination",
next: ".next a"
});
ias.extension(new IASSpinnerExtension());
ias.extension(new IASTriggerExtension({offset: 1}));
ias.extension(new IASNoneLeftExtension({text: 'There are no more posts.'}));
jQuery.ias().extension(new IASPagingExtension());
jQuery.ias().on('pageChange', function(pageNum, scrollOffset, url) {
console.log(
"Welcome at page " + pageNum + ", " +
"the original url of this page would be: " + url
);
});
</script>
I have tried to implement the below, it does not work:
if(url == '/website/home/2' && pageNum > 2) {
jQuery.ias().destroy();
}
I am using pagination from http://www.phpeasystep.com/phptu/29.html
pagination:
$targetpage = "home.php";
$limit = 10;
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit;
else
$start = 0;
$query2 = $pdo->prepare("select count(*) from table where...");
$query2->execute(array(':id' => $id));
$total_pages = $query2->fetchColumn();
if ($page == 0) $page = 1;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage - 1;
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<ul class=\"pagination\">";
if ($page > 1)
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$prev\">«</a></li>";
else
$pagination.= "<li class=\"disabled\"><a href=\"#\">«</a></li>";
if ($lastpage < 7 + ($adjacents * 2))
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li class=\"active\"><a href=\"#\">$counter<span class=\"sr-only\">(current)</span></a></li>";
else
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$counter\">$counter</a></li>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<li class=\"active\"><a href=\"#\">$counter<span class=\"sr-only\">(current)</span></a></li>";
else
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$counter\">$counter</a></li>";
}
$pagination.= "";
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$lpm1\">$lpm1</a></li>";
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$lastpage\">$lastpage</a></li>";
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=1\">1</a></li>";
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=2\">2</a></li>";
$pagination.= "";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<li class=\"active\"><a href=\"#\">$counter<span class=\"sr-only\">(current)</span></a></li>";
else
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$counter\">$counter</a></li>";
}
$pagination.= "";
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$lpm1\">$lpm1</a></li>";
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$lastpage\">$lastpage</a></li>";
}
else
{
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=1\">1</a></li>";
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=2\">2</a></li>";
$pagination.= "";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li class=\"active\"><a href=\"#\">$counter<span class=\"sr-only\">(current)</span></a></li>";
else
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$counter\">$counter</a></li>";
}
}
}
if ($page < $counter - 1)
$pagination.= " <li class=\"next\"><a href=\"$targetpage?page=$next\">»</a></li>";
else
$pagination.= "<li class=\"disabled\"><a href=\"#\">»</a></li>";
$pagination.= "</ul>\n";
}