How to Reinitialize ShareThis Buttons With Specific Sharing Parameters
Reinitializing the buttons would allow you to:
- Take control on when to display the buttons, for example, until a modal or pop-up opens up.
- Have different instances of the buttons on the same page with different configurations, for example, if you want to display only the twitter button on a specific part and the facebook one on another.
- Auto refresh share button properties when new links are loaded with share buttons (infinite scroll).
If you don’t want to reinitialize the buttons with specific parameters, you could just use the window.__sharethis__.initialize() function whenever your modal, pop-up, etc. activates. Please note that you may have to set a delay of around 0.3 to 1 second before adding the line of code above to give time for the container to appear, otherwise, the function will be called too soon
Once you’ve added the above portion of the code, you’re now able to include any or all of the following configuration options below.
- Please keep in mind that Open Graph tags will take precedence when sharing on Facebook and other social channels. If linking to a custom URL, please be sure to have Open Graph tags filled out for that page as well.
- As with our other tools, we recommend moving the site to live production before giving it a try as there are some resources that aren’t passed during a local/test environment.
Order of Precedence
It is important to remember the order of precedence by which the ShareThis code processes share properties. Generally, we recommend using one approach by which sharing properties are specified on your pages to prevent errors.
- Properties specified in tags (i.e. second precedence)
- Open Graph Protocol tags (i.e. lowest precedence)