繁体   English   中英

Tumblr之类的按钮在ajax加载后不起作用

[英]Tumblr like button not working after ajax load

我在tumblr主题中使用pjaxmasonry 我只是想出了在单击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);

});

资料来源: https : //github.com/defunkt/jquery-pjax#events

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM