问题
I am using pjax
and masonry
in my tumblr theme. I just figured out how to get masonry to work after clicking a pjax'd link, but now the problem is that the like button is not working anymore. Here is my code so far:
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);
});
回答1:
I believe you need to use pjax:success
. This should give you the data
object.
$(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);
});
Source: https://github.com/defunkt/jquery-pjax#events
来源:https://stackoverflow.com/questions/30120195/tumblr-like-button-not-working-after-ajax-load