jquery fancybox触发点击只工作一次 [英] jquery fancybox triggered click only working once

查看:256
本文介绍了jquery fancybox触发点击只工作一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从绑定到表行的点击事件调用jquery.fancybox链接。但是,如果我关闭fancybox并再次点击任何行,绑定到该行的匿名函数仍然会触发,但是fancybox不会启动。这里是我使用的javascript:

I am calling a jquery.fancybox link from the click event bound to a table row. The action works fine the first time, however, if I close the fancybox and click again on any row the anonymous function bound to the row still fires, but fancybox doesn't start up. Here's the javascript I'm using:

$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中,我将锚定为edit:

So, then in the HTML I have anchors classed as "edit":

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

我总是可以看到警告框,我可以更改trigger (),它将工作,在多个场合删除锚点。我也可以重复手动点击$('。edit')链接本身,这一切都很好。

I can always see the alert box, and I can change the trigger / click() call to remove() and it will "work", removing the anchors on multiple occasions. I can also repeatedly manually click the $('.edit') link itself and it's all good.

那么锚点击事件反过来从行点击事件?

So how is it that the anchor click event fires only once when coming in turn from the row click event? Is it something to do with the call I am making to $(this) when describing the function?

推荐答案

给这个一个镜头:

$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;
});

希望有所帮助!

这篇关于jquery fancybox触发点击只工作一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆