Using Tumblr Like Button with Infinite Scroll

后端 未结 1 1161
感动是毒
感动是毒 2020-12-01 17:29

I\'m trying to use the new Tumblr like buttons within Infinite Scroll (allowing your theme a like button on individual Tumblr posts from the homepage) they work for the firs

相关标签:
1条回答
  • 2020-12-01 18:15

    First you need to add a unique post ID to each of your posts:

    <div class="entry masonry-brick" id="{PostID}">...</div>
    

    The documentation mentions requesting the like status once the new posts (or new page) has been appended / loaded:

    function( newElements ) {
        var $newElems = $( newElements ).css({
            opacity: 0
        });
    
        // Create Array of $newElems IDs
        var $newElemsIDs = $newElems.map(function () { 
            return this.id; 
        }).get();
    
        $newElems.imagesLoaded(function(){
            $newElems.animate({
                opacity: 1
            });
            $container.masonry(
                'appended', $newElems, true
            );
    
            // Let's just see what we have, remove console.log() if working
            console.log($newElems, $newElemsIDs);
    
    
            Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
        });
    });
    

    I hope that points you in the right direction.

    0 讨论(0)
提交回复
热议问题