For ajax pages I call:
twttr.widgets.load()
but never happens, it doesn't reload twitter button.
I tried also with
twttr.widgets.load("nameDiv")
but I get this error:
TypeError: Object nameDiv has no method 'getElementsByTagName'
What am I doing wrong?
I solved with this solution (jQuery):
function reload_twitter_button() {
$('.social-tw').html('');
$('.social-tw').html('<a href="https://twitter.com/share" class="twitter-share-button" data-url="' + window.location.href + '">Tweet</a>');
// refresh the widgets
twttr.widgets.load();
}
I had the same issue. In my case, the page wasn't loaded before the load call was made. Wait for document ready to fire with:
$(function () {
function loadWidgets(){
twttr.widgets.load();
}
loadWidgets();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With