Ich benutze unendlich AJAX Scroll. Es funktioniert wie in ich kann klicken Sie auf mehr Elemente laden, und das lädt den Inhalt. Allerdings sollten ias auf der letzten Seite stoppen und zeigen ‚Es sind keine weiteren Beiträge‘, sondern es zeigt immer noch die ‚Last mehr Elemente‘ Link, wenn darauf geklickt wird wieder die Paginierung beginnt ab Seite 2.unendlich AJAX Scroll Paginierung Schleifen
Konsole:
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 sollte 'es sind keine weiteren Beiträge' angezeigt werden - stattdessen geht es wie folgt:
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>
Ich habe versucht, die unten zu implementieren, funktioniert es nicht:
if(url == '/website/home/2' && pageNum > 2) {
jQuery.ias().destroy();
}
ich Paginierung bin mit von http://www.phpeasystep.com/phptu/29.html
Paginierung:
$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";
}
Ich glaube, der Fehler ist Server_Seite. var_dump den Wert von $ total_pages unter anderen Variablen im PHP-Skript, um zu überprüfen. Obwohl eine einfache 'Hack'-Client-Seite wäre, die var pageNum mit den letzten Ziffern in der var-URL zu vergleichen. Wenn sie nicht gleich sind, dann zerstöre(), zeige eine Nachricht. –
Es ist nicht der $ total_pages Wert Ich habe das überprüft, ich denke, es ist das Paginierungsskript, das durch page1 und page2 läuft, kennt ihr irgendwelche Paginierungsskripte, die gut mit unendlichen Ajax Scroll funktionieren? – user3312792