[英]Tumblr like button not working after ajax load
我在tumblr主题中使用pjax
和masonry
。 我只是想出了在单击pjax链接后如何使砖石工作的方法,但是现在的问题是,like按钮不再起作用。 到目前为止,这是我的代码:
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);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.