Monday, April 23, 2012

Tumblr jQuery Like (grabbing from rel)

I coded a html5 (boilerplate) theme with masonry and infinite-scroll which so far has worked pretty well. Now I want to include reblog and like buttons on each post. I've tried to add this but for some reason the like button doesn't work.



URL to theme: http://inspiration.patrikarvidsson.com/



In the bottom of my script.js, I added this like-code.



$('a.like').click(function() {
var post = $(this).closest('.post');
var id = post.attr('id');
var oath = post.attr('rel').slice(-8);
var like = 'http://www.tumblr.com/like/'+oath+'?id='+id;
$('#likeit').attr('src', like);
$(this).toggleClass( 'liked' );
});


Complete scripts.js can be found here:
http://static.tumblr.com/e8lbmds/WB5m2q1it/scripts.js



And if needed, here's plugins.js: http://static.tumblr.com/e8lbmds/NDPm14qu6/plugins.js



The last line of the code above makes the link red; which I suppose indicates that the script responds. But no like is generated. Right after the initializing body tag, I have the following code:



<iframe id="likeit"></iframe>


Appertained css is the following:



#likeit { display: none; }
.liked, .like:hover { color: red !important; }


Any ideas why it's not working?





No comments:

Post a Comment