[英]sharethis on twitter bootstrap modal
I wanted to show the share-this widget on a twitter bootstrap modal, however the code says to do the following: 我想在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>
so what I did is that on bootstrap's shown.bs.modal event I have: 所以我做的是在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'});
});
however the next time I open a different modal, then this share button doesn't load. 但是,下次打开不同的模态时,则不会加载此共享按钮。 I assume it's because the getScript is already there? 我认为这是因为getScript已经存在了吗?
Try this after opening new modals: 打开新模态后尝试此操作:
stButtons.locateElements();
It will look for the new buttons and it will instantiate them. 它将查找新按钮,并将实例化它们。
Edit: Listen to the show.bs.modal
event to handle it : 编辑: 收听show.bs.modal
事件来处理它 :
$('#myModal').on('show.bs.modal', function () {
stButtons.locateElements();
})
Edit2: Ok after reading your comment I think that the final solution is: 编辑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.