我通过调用ajax函数来更新部分html页面每隔5分钟,就会有一些元素对象通过悬停打开一个弹出窗口。
我的代码运行第一个很好,但更新后工作不正常,每次悬停都会打开两个弹出窗口。(悬停功能调用两次)
index.php
<script type="text/javascript">
function refresh2() { <? php
echo CHtml::ajax(array(
'url' = > CController::createUrl("browsingpap/UpdateAjax"),
'update' = > '#type', )) ?>
}
window.setInterval("refresh2()", 300000);
</script>
<div id="type">
<!-- update here after call ajax function--->
</div>
更新Ajax
<script type="text/javascript">
$(document).ready(function() {
$("#goli").hover(function() {
$('#popup5').bPopup();
});
});
</script>
<div id="popup5" style="display: none;"> <span class="button b-close"><span>X</span></span>
<div class="content">popup window</div>
<div id="goli">hover me for show a popup</div>
</div>
试着这样做,看看它是否有帮助:
$("#goli").unbind('hover').bind('hover',function() {
$('#popup5').bPopup();
});
不管怎样,如果你发布其余的相关代码,它将帮助我们了解goig wrton是什么。