We're growing into something new. Read More
jonathanmoore

Jonathan Moore  Pro


$('div.loadedViaAJAX').find('a.twitter-share-button').each(function(i) {
var loadedTweetButton = new twttr.TweetButton($(this).get(0));
loadedTweetButton.render();
});

Render Tweet Button in AJAX Loaded Content

I'm working on changes to the Nova premium Tumblr theme to include infinite scrolling (jQuery plugin), but I was running into an issue where the official tweet button wasn't rendering for posts loaded via AJAX. Twitter's documentation doesn't include any methods to render the button after the DOM has originally loaded. Using a JavaScript unminifier I was able to figure out a way to call and render a new tweet button. I could have used the iframe version of the button, but the theme uses several of the data types for more control over the tweet content.