tumblr喜欢按钮不是阿贾克斯后负荷工作负荷、按钮、不是、喜欢

2023-09-10 21:58:39 作者:梦毁少年过度沉醉ゼ

我使用 pjax 和我的tumblr主题砖石。我只是想出了如何让砖石单击pjax'd链接后工作,但现在的问题是,像按钮不工作了。这是我的code到目前为止:

HTML:

 <物品类=项ID ={PostID}>

< /条>
 

jQuery的:

  $(文件).ajaxComplete(函数(){
   $('#内容)。imagesLoaded(函数(){
      $('#内容)砌体('reloadItems')砌筑()。
   });

   变量$ newPosts = $(数据).find(条目。');
   变量$ newPostIDs = $ newPosts.map(函数(){
     返回this.id;
   })。得到();

   Tumblr.LikeButton.get_status_by_post_ids($ newPostIDs);
});
 

解决方案

我相信你需要使用 pjax:成功。这应该给你的数据对象。

  $(文件)。在('pjax:成功',功能(事件,数据,身份,XHR,期权){

 $('#内容)。imagesLoaded(函数(){
    $('#内容)砌体('reloadItems')砌筑()。
 });

 变量$ newPosts = $(数据).find(条目。');
 变量$ newPostIDs = $ newPosts.map(函数(){
   返回this.id;
 })。得到();

 Tumblr.LikeButton.get_status_by_post_ids($ newPostIDs);

});
 
11月19日,我喜欢的阿贾克斯和曼城来啦

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

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);
});

解决方案

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