I am using the official Tweet Button from Twitter to allow users to share my site.
The button itself is working just fine, however the counter doesn\'t work and stays at
I had luck switching from the URL parameter method to the data- attributes method.
function twtrButton(url, text, configs){
// Create a link
var params = {
rel: 'canonical',
'data-count': 'horizontal',
href: 'http://twitter.com/share/'
};
if (url) {
params['data-url'] = url;
params['data-counturl'] = url;
}
if (text) {
if(text.length > 90){
text = text.substring(0, 90);
text += '...';
}
params['data-text'] = text;
}
if (configs) {
if (configs.via) {
params['data-via'] = configs.via;
}
if (configs.related) {
params['data-related'] = configs.related;
}
}
var link = $('<a>', params).addClass('twitter-share-button');
return link;
}
This snippet assumes jQuery 1.5 or greater.