[Resolved] jquery event on load more posts in infinite scroll

Home Forums Support [Resolved] jquery event on load more posts in infinite scroll

Home Forums Support jquery event on load more posts in infinite scroll

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #643953
    Joshua Vandercar

    I’d like to run a jquery function when more posts are loaded via infinite scroll. Is there an event to which I can bind? Thanks!

    #644203
    Leo
    Staff
    Customer Support

    Hi there,

    Infinite Scroll for posts is a built in feature:
    https://docs.generatepress.com/article/blog-content-layout/#archives

    Let me know if this helps πŸ™‚

    #644253
    Joshua Vandercar

    Yes, I have that enabled. Is there a specific javascript event that is triggered after the additional posts are loaded? I have a function that needs to target and modify those elements that are being added to the DOM.

    #644588
    Tom
    Lead Developer
    Lead Developer

    Give this a shot:

    jQuery( document ).ready( function($) {
        var $container = $( '#main article' ).first().parent();
    
        $container.on( 'append.infiniteScroll', function( event, response, path, items ) {
            // Do stuff
        } );
    } );

    Make sure to load this JS only on pages that have infinite scroll initiated.

    Let me know πŸ™‚

    #644602
    Joshua Vandercar

    Yes! Thank you, Tom! That got the job the done.

    #644864
    Tom
    Lead Developer
    Lead Developer

    Awesome! You’re welcome πŸ™‚

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.