gpt4 book ai didi

javascript - jquery fancybox 触发点击只工作一次

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:52:18 27 4
gpt4 key购买 nike

我从绑定(bind)到表格行的点击事件中调用一个 jquery.fancybox 链接。该操作第一次运行良好,但是,如果我关闭 fancybox 并再次单击任何行,绑定(bind)到该行的匿名函数仍然会触发,但 fancybox 不会启动。这是我正在使用的 javascript:

$jq(document).ready(function() {

$jq('a.edit').fancybox({
'overlayShow': true,
'hideOnContentClick': false
});

$jq('tr').click(function() {
alert("clicked");
$jq(this).find('a.edit').trigger("click");
});

});

那么,在 HTML 中我将 anchor 分类为“编辑”:

<tr>
<td>...</td>
<td>
<a href="/candidates/22/qualifications/16/edit" class="edit">edit</a>
</td>
</tr>

我总能看到警告框,我可以将 trigger/click() 调用更改为 remove(),它会“起作用”,多次删除 anchor 。我也可以反复手动单击 $('.edit') 链接本身,这一切都很好。

那么 anchor 击事件是如何在行点击事件依次过来时只触发一次的呢?这与我在描述函数时对 $(this) 的调用有关吗?

最佳答案

试一试:

$jq('a.edit').live('click',function(){
$.fancybox('<div>Here is the content</div>'{
overlayShow: true,
hideOnContentClick: false
});

return false;
});

或者,您可以:

 $jq('a.edit').live('click',function(){
$.fancybox({
href: 'some-page.html'
overlayShow: true,
hideOnContentClick: false
});

return false;
});

希望对您有所帮助!

关于javascript - jquery fancybox 触发点击只工作一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2038071/

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