遵循guide,我可以通过ajax启动addthis,但它只在一个地方有效,
例如,
html索引页'index.php',
<a href="#" class="load">click to load</a>
<div id="container"></div>
<p>addthis at the footer,</p>
<div class="addthis_toolbox addthis_default_style left addthis" style="border:0px solid #000; margin:20px 5px 0px 10px; width:300px;">
<a class="addthis_button_facebook_like" addthis:url="#" addthis:title="#" addthis:description="#" fb:like:layout="button_count" style="width:80px;"></a>
<a class="addthis_button_tweet" addthis:url="#>" addthis:title="#" addthis:description="#" style="width:100px;"></a>
<a class="addthis_button_google_plusone" g:plusone:size="medium" style="width:65px;"></a>
</div>我在ajax页面中还有另一个addthis按钮-- 'load.php',
<p>it should have another addthis in this ajax loaded page,</p>
<a class="addthis_button_facebook" addthis:url="#" addthis:title="title" addthis:description="" href="http://www.addthis.com/bookmark.php?v=250&username=lauthiamkok"></a>
<a class="addthis_button_twitter" addthis:url="#" addthis:title="title" addthis:description="" href="http://www.addthis.com/bookmark.php?v=250&username=lauthiamkok"></a>
<a class="addthis_button_google_plusone" addthis:url="#" addthis:title="title" addthis:description="" href="http://www.addthis.com/bookmark.php?v=250&username=lauthiamkok"></a>这是我的jquery,
$(document).ready(function(){
// the addthis buttons are loaded successfully here.
initAddThis();
$('.load').click(function(){
$('#container').load('load.php', function(){
// the addthis buttons fail to load here.
initAddThis();
});
return false;
});
});
function initAddThis()
{
addthis.init()
}它只发生在索引页面上,而不是ajax页面上...我该如何解决这个问题呢?
发布于 2011-11-07 21:41:31
您使用了错误的示例代码:)您发布的代码用于在使用ajax加载所有内容之后初始化addThis。
您正在寻找一种使用addthis更新/初始化某些链接的方法。
我认为这会对你有所帮助:Rendering with JavaScript
发布于 2012-05-30 21:30:52
您需要将您的initAddthis函数移动到window.onload方法,以便在加载页面的所有资产时触发该函数。
window.onload = function(){
initAddthis();
}发布于 2013-08-28 14:51:45
尝尝这个
var addthis_url = "http://s7.addthis.com/js/250/addthis_widget.js#pubid=your_id";
if (window.addthis) {
window.addthis = null;
window._adr = null;
window._atc = null;
window._atd = null;
window._ate = null;
window._atr = null;
window._atw = null
}
$.getScript(addthis_url)https://stackoverflow.com/questions/8037092
复制相似问题