TIM*_*MEX 7 javascript ajax jquery addthis
基本上,这就是我正在做的事情.用户访问网站,加载"index.html"在index.html中,它会自动通过AJAX将"details.html"加载到DIV中.我在"details.html"上放了一个ADDTHIS按钮.但是,出于某种原因,翻转不起作用.
当我在浏览器中访问details.html时,翻转工作正常.我猜这是因为AJAX?
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4adf7e45288f5b21">
<img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0;margin-top:16px;"/></a>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4adf7e45288f5b21"></script>
Run Code Online (Sandbox Code Playgroud)
小智 14
我最近遇到了在所有AJAX网站上使用AddThis的问题,并且能够针对这个问题提出几个解决方案.
事实证明,在加载AJAX脚本时可以传递一个变量,以及在通过AJAX重新加载DOM时重新初始化脚本的方法.我已经在我的博客上详细发布了完整的解决方案:
http://joecurlee.com/2010/01/21/how-to-use-addthis-with-ajax-and-overflowauto/
简而言之,解决方案是加载附加了变量domready = 1的AddThis,并通过删除初始加载然后动态重新加载脚本来重新初始化脚本:
var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
if (window.addthis){
window.addthis = null;
}
$.getScript( script );
Run Code Online (Sandbox Code Playgroud)
如果我正确理解你的问题,在 ajax 函数的回调中,将翻转绑定到 add-this 按钮。
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(){
$('.addthis_button').hover(
function(){
//do mouse over
},function(){
//do mouse out
});
}
});
Run Code Online (Sandbox Code Playgroud)
你也可以尝试
$('.addthis_button').live('mouseover',function(){//do mouseover});
$('.addthis_button').live('mouseout',function(){//do mouseout});
Run Code Online (Sandbox Code Playgroud)
我从未使用过 live,但它似乎对你有用,因为你的 add_this 按钮是在 $(document).ready() 之后创建的
| 归档时间: |
|
| 查看次数: |
10715 次 |
| 最近记录: |