I'm trying to use this script to AJAX load paginated entries in EE. There may be a far simpler way to do it though.
This script works, but replaces the current 10 entries with the next 10 entries, but instead I would like the next 10 entries to be appended to the list.
Also, clicking the Show More button should keep adding the next 10 '<article>
's and then the Show More button should disappear once there are no more to show.
<section id="articles">
{exp:channel:entries channel="page" sort="asc" orderby="title" limit="10" paginate="bottom" dynamic="no"}
<article>
<h2>{title}</h2>
{page_summary}
</article>
{paginate}
{pagination_links}
<ul class="pagination">
{next_page}
<li><a href="{pagination_url}">Show More</a></li>
{/next_page}
</ul>
{/pagination_links}
{/paginate}
{/exp:channel:entries}
</section>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
(function(a) {
a.fn.pager = function(b) {
var d = "#" + a(this).attr("id");
var c = {
link: ".pagination a",
pull: d + " > *",
loaderID: "loader",
scrollTo: "body",
fadeSpeed: 100,
fadeOpacity: 0.5
};
var b = a.extend(c, b);
a(b.link).live("click", function(g) {
g.preventDefault();
var f = a(this).attr("href");
a(d, function() {
a(d).fadeTo(b.fadeSpeed, b.fadeOpacity);
a(d).after('<i id="' + b.loaderID + '" style="display: none;"></i>');
a("#" + b.loaderID).fadeIn(b.fadeSpeed)
}).load(f + " " + b.pull, function() {
a(d).fadeTo(b.fadeSpeed, 1);
a(window).scrollTop(a(b.scrollTo).position().top);
a("#" + b.loaderID).fadeOut(b.fadeSpeed, function() {
a("#" + b.loaderID).remove()
})
})
})
}
})(jQuery);
</script>
<script>
$(document).ready(function() {
$('#articles').pager();
});
</script>
I wondered if anyone might be able to point me in the right direction?