【发布时间】:2017-03-28 18:53:48
【问题描述】:
我正在设计一个同时使用 Masonry 和无限滚动代码的 tumblr 主题。 The infinite scrolling code is here,如果您需要查看它。点赞按钮在所有帖子上都正确显示,并且适用于前几篇帖子,但不适用于新加载的帖子。
每个帖子都添加了 {PostID} id。我对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 谢谢!我已经修复了这个错误,但是点赞按钮仍然不起作用。
-
我不同意,它是重复的,我的投票仍然存在。
标签: javascript jquery tumblr