CMS Development

SiJack
Member

Prevent 'load more' button when all content visible

Hi

 

We have instances where the filtered list of post content is complete, yet the load more button is still appearing. Can anyone help with the code needed to disable or hide the button when all posts are present?

 

Here's an example listing page:

https://www.ardoq.com/resources/author/webinar

 

And the current code used for the button:

 

<script src="{{ get_asset_url('/Website 2020/Assets/JS/libraries/infinite-ajax-scroll.js') }}"></script>
<script>
$(document).ready(function(){
window.ias = new InfiniteAjaxScroll('.related-posts', {
item: '.listing-post',
next: '.next-posts-link',
pagination: '.blog-pagination',
trigger: {
element: function() {
let el = document.createElement('button');
el.innerText = 'Load More';
el.className = "ias-trigger";
document.querySelector('.related-posts').appendChild(el);
return el;
}
}
});
});
</script>

 

Thanks, Si

0 Upvotes
2 Replies 2
SiJack
Member

Prevent 'load more' button when all content visible

Hi @Jaycee_Lewis I have not considered that...simply because knowing how to create that function is a bit beyond my obscenely rudimentay capabilities 😄

Would you have any pointers?

Thanks so much!

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Prevent 'load more' button when all content visible

Hey, @SiJack 👋 Thanks for your question! 

 

Have you considered adding a check for whether all posts are already visible? By using a function that counts the total number of displayed posts, compares it to the total posts count, and then decides whether to display the 'load more' button.

 

 

Talk soon! — Jaycee


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !