2010-09-22 39 views

回答

43

添加新的內容到DOM後,調用

stButtons.locateElements(); 

// or if you want to be a bit defensive about whether the lib has been 
// loaded or not: 
if (window.stButtons){stButtons.locateElements();} // Parse ShareThis markup 

Articleanotheranother

+0

你剛剛救了我很多狩獵:)。 – 2013-04-26 00:43:12

+0

你是一個非常好的人。讓我的一天! – jerrygarciuh 2013-10-29 19:39:03

+0

@jerrygarciuh嗨傑裏,很高興有幫助!感謝您的評論和upvote。 – 2013-10-30 06:28:41

-3

我發現下面的解決方案在前頁論壇之一,它的工作對我很好。 我調用函數作爲我的ajax調用的回調函數。好吧,這有助於

<script type="text/javascript"> 
     function ReinitializeAddThis(){ 
     if (window.addthis){ 
     window.addthis.ost = 0; 
     window.addthis.ready(); 
     } 
    } 
... 
$('#camps-slide .results').load(loc+suffix, function() {ReinitializeAddThis();}); 
</script> 
+1

,沒有任何意義。什麼是陣營 - 幻燈片或祿和後綴代表什麼地方?最好把你的網址從 – bicycle 2013-03-22 14:28:46

2

我正面臨與sharethis和Ajax分頁相同的問題。 Ajax發佈的帖子沒有顯示按鈕,所以我搜索並找到了它。 我剛加入的功能stButtons.locateElements();關於Ajax success:

success:stButtons.locateElements();

希望這將是對我這樣的人有幫助。

感謝 Ibnul

3

該解決方案還將努力爲基礎的NodeJS框架,像流星。

stButtons.locateElements(); 

需要在呈現的模板回調中,以確保shareThis按鈕將出現在頁面上重定向。

0

在Drupal,你可以通過添加如下代碼

(function($){ 
Drupal.behaviors.osShareThis = { 
attach: function(context, settings) { 
    stLight.options({ 
    publisher: settings.publisherId 
    }); 
    // In case we're being attached after new content was placed via Ajax, 
    // force ShareThis to create the new buttons. 
    stButtons.locateElements(); 
} 
}; 
}); 
實現這一
4

更新09/2017回答

的stButtons對象不存在了,現在你可以使用

window.__sharethis__.initialize() 

重新初始化按鈕

+0

謝謝。我搜索了幾天,覺得我瘋了,因爲我是唯一一個不能使用stButton的人。完成。 – 2017-09-21 22:02:10

1

對於新API以下解決方案爲我工作

if (__sharethis__ && __sharethis__.config) { 
    __sharethis__.init(__sharethis__.config); 
} 

加載ajax內容後添加此代碼。

相關問題