簡體   English   中英

在twitter bootstrap模式上分享這個

[英]sharethis on twitter bootstrap modal

我想在twitter bootstrap模式上顯示共享 - 這個小部件,但代碼說要執行以下操作:

<span class='st_facebook_hcount' displayText='Facebook'></span>
<span  class='st_twitter_hcount' displayText='Tweet'></span>
<span class='st_plusone_hcount' displayText='Google +1'></span>
<span  class='st_email_hcount' displayText='Email'></span>

所以我做的是在bootstrap的shown.bs.modal事件中我有:

var switchTo5x=true;
    $.getScript("http://w.sharethis.com/button/buttons.js", function(){
        stLight.options({publisher: "c68c8f6c-c670-419b-b8e2-23772e22a861", doNotHash: false, doNotCopy: false, hashAddressBar: false, popup: 'true'});

    });

但是,下次打開不同的模態時,則不會加載此共享按鈕。 我認為這是因為getScript已經存在了嗎?

打開新模態后嘗試此操作:

stButtons.locateElements();

它將查找新按鈕,並將實例化它們。

編輯: 收聽show.bs.modal事件來處理它

$('#myModal').on('show.bs.modal', function () {
  stButtons.locateElements();
})

編輯2:看完你的評論后,我認為最終的解決方案是:

var switchTo5x=true;
    $.getScript("http://w.sharethis.com/button/buttons.js", function(){
        stLight.options({publisher: "c68c8f6c-c670-419b-b8e2-23772e22a861", doNotHash: false, doNotCopy: false, hashAddressBar: false, popup: 'true'});
        stButtons.locateElements();
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM