gpt4 book ai didi

javascript - 在推特 Bootstrap 模式上分享这个

转载 作者:行者123 更新时间:2023-11-30 12:52:37 25 4
gpt4 key购买 nike

我想在 Twitter Bootstrap 模式上显示 share-this 小部件,但是代码说要执行以下操作:

<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();

它将寻找新按钮并将它们实例化。

编辑:Listen to the show.bs.modal event to handle it :

$('#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();
});

关于javascript - 在推特 Bootstrap 模式上分享这个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20396739/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com