I am designing a tumblr theme that uses both Masonry and an infinite scroll code. The infinite scrolling code is here, if you need to view it. The like button shows up correctly on all posts, and works on the first few posts, but doesn't work on newly loaded posts.
Each post has the {PostID} id added to it. I have a really poor understanding of Javascript, so I think that's where the problem is:
$(function(){
var $container = $('#content');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.entry',
isAnimated:true,
columnWidth:1,
animationOptions:{duration:350, queue:false},
isFitWidth: true,
});
});
$container.infinitescroll({
navSelector : '#page-nav', // selector for the paged navigation
nextSelector : '#page-nav a', // selector for the NEXT link (to page 2)
itemSelector : '.entry', // selector for all items you'll retrieve
loading: {
finishedMsg: '{lang:No more posts}',
img: 'http://24.media.tumblr.com/tumblr_m3j5g3KlEm1r0fipko8_r1_100.gif'
}
},
// trigger Masonry as a callback
function( newElements ){
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
isAnimated:true
$container.masonry( 'appended', $newElems, true );
});
// videos
$newElems.find('.video').each(function(){
resizeVideos();
console.log($newElems, $newElemsIDs);
Tumblr.LikeButton.get_status_by_post_ids($newElemsIDs);
},
function(){
$container.masonry();
});
}
);
});
Any help would be greatly appreciated!