javascript - Tumblr like button not working after ajax load -


i using pjax , masonry in tumblr theme. figured out how masonry work after clicking pjax'd link, problem button not working anymore. here code 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 need use pjax:success. should give 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


Comments