我正在設計一個同時使用砌體和無限滾動代碼的tumblr主題。 The infinite scrolling code is here,如果你需要查看它。類似的按鈕在所有帖子上正確顯示,並在前幾個帖子上工作,但不適用於新加載的帖子。Tumblr Like Button Not Working
每個帖子都添加了{PostID}標識。我有JavaScript的一個真正的窮人的理解,所以我認爲這是問題的所在:
$(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();
});
}
);
});
任何幫助將不勝感激!
您有一個額外的** **逗號在這一行的結尾:'isFitWidth:true,'它應該是這樣的:'isFitWidth:true' – EhsanT
@EhsanT謝謝!我已修復此錯誤,但類似的按鈕仍然無法正常工作。 –
請參閱這樣的回答:http://stackoverflow.com/a/16396022/1238244 – lharby