I used to use this snippet to re-render a Tweet button.
var tweetButton = new twttr.TweetButton(twitterScript);
twttr.render();
But it looks like widgets.js (http://platform.twitter.com/widgets.js) has been modified so twttr.TweetButton is no longer a constructor.
Can anyone help with this issue?
First, make sure you have jQuery included in your document's head:
Then create a link that has the same URL as the eventual tweet button, along with an empty div where your button will be rendered:
At the bottom of your page, right above the /body tag, include the javascript from Twitter and the function that will render the button, as well as the listener that will activate the function when the desired event takes place:
Lastly, add a link to your page somewhere that will activate the function above based on some event:
That's it.
If you want the entire test HTML page to see how I've got it working, see here:
Try the @Anywhere library. Sample js code:
I found the answer on the web. The idea is to re-request the Twitter javascript file. As it is cached, there is no download overhead.
Looks like the
twttr.TweetButton
constructor was never supported, and now no longer works after the last API update:The supported method is to create an
iframe
-based Tweet button dynamically:Although note @Runningskull’s answer for updated information.
you just need to call
twttr.widgets.load()
after your ajax call. no need to reload a script that is already loaded.I just had the same problem, this works in JQuery: