Jonathan
Jonathan

Reputation: 32868

How do I refresh the sharing URL for the AddThis Facebook button?

I'm using AddThis to render group of social media icons in the header of each page of my web app.

This is a Single Page Application (SPA), built on Angular.

So whenever the user navigates to another page, there's not a full page reload, but the components on the page are reloaded.

The trouble is, all the AddThis configuration stays the same. So even when the social media buttons get refreshed, the same sharing URL is shown when the user clicks the Facebook sharing button.

How can I clear this and replace it with the current page URL on each page reload?

Upvotes: 3

Views: 2333

Answers (2)

eh1160
eh1160

Reputation: 694

I had the same problem, but I found out that you could simply call addthis.toolbox() when you want the links to update.

Upvotes: 0

Jonathan
Jonathan

Reputation: 32868

From mucking around in the Chrome Console, I discovered a global property, addthis_share, which seems to allow me to update the sharing URL.

So I used code like this to updated it on each page reload:

window['addthis_share'].url = window.location.href;
window['addthis_share'].title = window.document.title;

I've encapsulated all the reloading code into a function, addthis_reload.

Upvotes: 1

Related Questions