How to reload Twitter button?

For ajax pages, I call:

twttr.widgets.load ()

but never happens, it does not reload the twitter button.

I tried also with

twttr.widgets.load ("nameDiv")

but I get this error:

TypeError: Object nameDiv does not have a method 'getElementsByTagName'

What am I doing wrong?

+7
source share
2 answers

I decided with this solution (with jQuery) other better ideas?

function tw_reload() // reload tweet 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(); } 
+9
source

I had the same problem. In my case, the page was not loaded before the download request was made. Wait until the document is ready to work with:

 $(function () { function loadWidgets(){ twttr.widgets.load(); } loadWidgets(); }); 
+1
source

All Articles