Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto load fancybox using .trigger('click')

I was just wondering if you could please help. I am trying to get the fancybox to load automatically once the page is rendered. However, I got this error message 't is undefined' at line 18 (/js/fancybox/ jquery.fancybox-1.3.3.pack.js). At the moment, I am 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 firebug console then it WORKS!. Not sure what did I do wrong here. Your helps would be grateful.

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

Thanks

like image 301
Hung Bui Avatar asked Nov 25 '25 07:11

Hung Bui


1 Answers

I got the same problem. Testing with the unpacked version, i got "loading is undefined" in line 36 (fancybox 1.3.4). So I called "$.fancybox.init();" before triggering and it works correctly now.

like image 107
Krevindiou Avatar answered Nov 27 '25 21:11

Krevindiou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!