我在我的 tumblr 主题中使用 pjax
和 masonry
。我刚刚弄清楚如何在单击 pjax 链接后让砌体正常工作,但现在的问题是“喜欢”按钮不再起作用。这是到目前为止我的代码:
html:
<article class="entry" id="{PostID}">
</article>
jquery:
$(document).ajaxComplete(function(){
$('#content').imagesLoaded(function(){
$('#content').masonry('reloadItems').masonry();
});
var $newPosts = $(data).find('.entry');
var $newPostIDs = $newPosts.map(function () {
return this.id;
}).get();
Tumblr.LikeButton.get_status_by_post_ids($newPostIDs);
});
最佳答案
我相信您需要使用pjax:success
。这将为您提供 data
对象。
$(document).on('pjax:success', function( event, data, status, xhr, options ) {
$('#content').imagesLoaded(function(){
$('#content').masonry('reloadItems').masonry();
});
var $newPosts = $(data).find('.entry');
var $newPostIDs = $newPosts.map(function () {
return this.id;
}).get();
Tumblr.LikeButton.get_status_by_post_ids($newPostIDs);
});
关于javascript - Ajax 加载后 Tumblr 之类的按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30120195/