Automatically load fancybox using .trigger ('click')

I'm just wondering if you can help. I am trying to get fancybox to load automatically after the page is rendered. However, I received this error message 't is undefined' on line 18 (/ js / fancybox / jquery.fancybox-1.3.3.pack.js). I'm currently using jquery version 1.4.2

<a href="#container" id="profile">Click me</a>

<div style="display:none">
<div id="container">Fancybox Content Here .... </div>
</div>

<script type="text/javascript">
$(document).ready(function(){
      $('#profile').fancybox().trigger('click');

});

</script>

The funny thing is, if I take the line below and run it in the firebug console, then it WORKS !. Not sure what I did wrong here. Your help would be greatly appreciated.

 $('#profile').fancybox().trigger('click');

thank

+3
source share
3 answers

. , " undefined" 36 (fancybox 1.3.4). "$.fancybox.init()"; , .

+13

, fancybox.js , , ​​

0

I handled a similar case as follows:

$(".some_wrapper").on('click', function(){
    var lnk = $(this).find("a").first();
    if (hr && ~cls.indexOf("fancybox-a")) {
        $.fancybox(lnk);
    }
});
0
source

Source: https://habr.com/ru/post/1780210/


All Articles