Skip to content

Instantly share code, notes, and snippets.

@battlejj
Created April 25, 2012 14:51
Show Gist options
  • Save battlejj/2490314 to your computer and use it in GitHub Desktop.
Save battlejj/2490314 to your computer and use it in GitHub Desktop.
Tweet button doesn't work
.custom-tweet-button a {
display: block;
padding: 2px 5px 2px 60px;
color:#2A7090;
background: url("http://platform0.twitter.com/widgets/images/tweet.png") no-repeat scroll 0 0 transparent;
}
.twitterDiv {
float:left;
border:none;
font-weight:bold;
}
//you'll need jQuery ;)
$('.twitterDiv').each(function(){
effTwitter($(this));
});
function effTwitter($obj){
var count = 0;
$.ajax({
url: 'http://urls.api.twitter.com/1/urls/count.json?twitterCacheSux=1&url=' + encodeURIComponent($obj.attr("rel")),
dataType: "jsonp",
success: function(response){
console.log(response);
console.log(response.count);
count = parseInt(response.count);
$obj.find(".custom-tweet-button a").html(count);
}
})
}
<div class="twitterDiv" rel="http://yoururlhere.com/whatever/article">
<div class="custom-tweet-button">
<a href="http://twitter.com/share?url=#urlencodedformat('http://yoururlhere.com/whatever/article')#" target="_blank"></a>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment