fancybox bug with trigger click

前端 未结 4 1171
孤城傲影
孤城傲影 2020-11-28 15:26

I have to run fancybox with trigger click in my website, the problem that i discovered is that with this method if you click on elements in

4条回答
  •  野性不改
    2020-11-28 15:43

    I had the same symptom of an unclickable Fancybox overlay. My client wanted to be able to link and automatically open up a certain Fancybox, like http://yoursite.com/#signup to open up an inline 'signup' Fancybox overlay. Thanks to JFK I realized I was triggering and targeting the element with the ID of 'signup' rather than the element with the href attribute of '#signup'. I got it to hook onto the last portion of the URL (i.e. #signup) and look up the matching 'a' href attribute, and to trigger a click on that element.

    The demo below doesn't really help portray this, but you get to see the code.

    http://jsfiddle.net/ca7no4yp/2/

    The juicy bit:

    $("a[href='#" + location.href.substr(location.href.indexOf('#')+1) + "']").fancybox().trigger('click');
    

提交回复
热议问题