Frage

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?

War es hilfreich?

Lösung 2

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top