2
votes

I'm currently working on a website where the content is loaded via AJAX, every piece of content has some AddThis sharing buttons.

So after the content is loaded and added into a div container, I reload the AddThis script in order to make it work again:

var script = 'http://s7.addthis.com/js/250/addthis_widget.js#pubid=myid&domready=1';
if(window.addthis) window.addthis = null;
$.getScript( script );

But when I share the page, I noticed that the title and url don't change, I did change the title manually:

var title = $(response).find('h2').text();
window.document.title = title;
window.history.pushState({path: href}, title, href);

Why won't AddThis use this new title and URL? Also for the Facebook sharing it's using the image from the first content. (probably because of the wrong url)

2
Even when setting the addthis:url and addthis:title myself it still takes the title from the first page loaded. - woutr_be
Apparently I forgot to call addthis.update(), this fixed my problem. stackoverflow.com/questions/7514878/… - woutr_be

2 Answers

2
votes

Apparently I forgot to call addthis.update(), this fixed my problem.

AddThis buttons wont update to include fragment (#Hash Tag)

0
votes

You could try this too (I found a bug in IE8, becauses AddThis uses for..in:

for(var i = 0; i < addthis.links.length; i++){
    addthis.links[i].share.url = "new url";
    addthis.links[i].share.title = "new title";
}