In the first place I want to say sorry for my bad english . I'm trying to develop a tumblr theme , and add a 'loading more' button . I used JavaScript to determinate the current page and the next one . When 'Loading More' button is pressed , I use jQuery to make a request to next tumblr page ex ( sitename.tumblr.ro/page/next-page ) , get the html , extract the posts html and append it to current page . But the problem is that the like button is not working on the appended posts . When I click the button , noting is happening . The cursor is not even pointing ... Here's my javascript code :
var $holder = $('div.posts_holder');
var page = null;
$(document).on('click','div.loading_more.loading_trigger',function(){
if(page == null)
{
page = window.location.href.search('page') > -1 ? window.location.href.split('/')[window.location.href.split('/').length-1] : 1;
}
page = Number(page)+1;
$(this).text('Please Wait..');
var load_page = '{BlogURL}page/'+page;
var $saved = $(this);
//get the page
$.get(load_page,function(response)
{
var $append_html = $(response).find('div.posts_holder');
if($append_html.html().replace(' ','').trim() == '')
{
$saved.removeClass('loading_trigger');
}
$saved.text('Loading More');
$holder.append($append_html.html()).masonry();
$holder.masonry( 'reloadItems' );
$holder.masonry( 'layout' );
setTimeout(function(){
$holder.masonry( 'reloadItems' );
$holder.masonry( 'layout' );
},800);
});
});
I found the answer . You must add :Tumblr.LikeButton.get_status_by_page(page); to your javascript after you added new items ,where 'page' is the number of page you just added.