How to reinitialize ShareThis buttons with specific sharing parameters
In this guide we’ll teach you how to reinitialize (reload) our ShareThis buttons to use specific sharing parameters. An example of using this guide would be to auto refresh share button properties when new links are loaded with share buttons (infinite scroll). By default the ShareThis widget loader loads as soon as the browser encounters the JavaScript tag; typically in the tag of your page. ShareThis assets are generally loaded from a CDN closest to the user. However, if you wish to change the default setting so that the widget loads after your web-page has completed loading then you simply set a parameter in the page.
Add Javascript
// render the html <div id="my-inline-buttons"></div> // load the buttons window.__sharethis__.load('inline-share-buttons', {
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.
Note: 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.
Configuration Options
config = { alignment: STRING, // left, right, center, justified. container: STRING, // id of the dom element to load the buttons into enabled: BOOLEAN, font_size: INTEGER, // small = 11, medium = 12, large = 16. id: STRING, // load the javascript into a specific dom element by id attribute labels: STRING, // "cta", "counts", or "none" min_count: INTEGER, // minimum amount of shares before showing the count padding: INTEGER, // small = 8, medium = 10, large = 12. radius: INTEGER, // in pixels networks: ARRAY[STRING], show_total: BOOLEAN, show_mobile_buttons: BOOLEAN, // forces sms to show on desktop use_native_counts: BOOLEAN, // uses native facebook counts from the open graph api size: INTEGER, // small = 32, medium = 40, large = 48. spacing: INTEGER, // spacing = 8, no spacing = 0. };
Available Networks
'blogger' 'delicious' 'digg' 'email' 'facebook' 'flipboard' 'googleplus' 'linkedin' 'livejournal' 'mailru' 'meneame' 'messenger' 'odnoklassniki' 'pinterest' 'print' 'reddit' 'sharethis' 'sms' 'stumbleupon' 'tumblr' 'twitter' 'vk' 'wechat' 'weibo' 'whatsapp' 'xing'
Example
// render the html <div id="my-inline-buttons"></div> // load the buttons window.__sharethis__.load('inline-share-buttons', { alignment: 'left', id: 'my-inline-buttons', enabled: true, font_size: 11, padding: 8, radius: 0, networks: ['messenger', 'twitter', 'pinterest', 'sharethis', 'sms', 'wechat'], size: 32, show_mobile_buttons: true, spacing: 0, url: "https://www.sharethis.com", // custom url title: "My Custom Title", image: "https://18955-presscdn-pagely.netdna-ssl.com/wp-content/uploads/2016/12/ShareThisLogo2x.png", // useful for pinterest sharing buttons description: "My Custom Description", username: "ShareThis" // custom @username for twitter sharing });