Last Updated: February 25, 2016
·
2.754K
· zukk0

Social plugins re-parsing

You might need to change the link of the like/share buttons in your page in real time.
In this case you need to reload the social plugin using the following methods.

// Twitter
twttr.widgets.load();

// Facebook
// general to all elements in the page
FB.XFBML.parse();
// single element with an id
FB.XFBML.parse(document.getElementById('element_id'));

// G+
gapi.plusone.render('element_id', {
'size' : 'medium'
// options as you need them
});

//Pinterest
$.ajax({ url: 'http://assets.pinterest.com/js/pinit.js', dataType: 'script', cache:true});

Have a fresh tip? Share with Coderwall community!

Post
Post a tip