jquery - Fancybox only working sometimes without refreshing the page -
i'm using fancybox users can click on image thumbnails , see larger images.
the problem i'm having doesn't work when page loads. i'll click on thumbnails , fancybox doesn't show larger images. if refresh page however, works fine. content generated dynamically wonder if need refresh dom?
<script type="text/javascript"> $(document).ready(function() { $(".fancybox").fancybox({ openeffect : 'fade', // openeffect / closeeffect / nexteffect / preveffect closeeffect : 'fade', // animation effect ('elastic', 'fade' or 'none') each transition type nexteffect : 'fade', // string; default value: 'fade', 'fade', 'elastic', 'elastic' preveffect : 'fade', openspeed : '1000', // openspeed / closespeed / nextspeed / prevspeed closespeed : '1000', // time takes (in ms, or "slow", "normal", "fast") complete transition nextspeed : '1000', // integer; default value: 250 prevspeed : '1000', padding : 3 }); }); </script> <a class='fancybox' rel='gallery' href='".$data['photo'][$x]."'><img src='".$data['photo'][$y]."' style='margin-right: 2.5px; margin-left: 2.5px; vertical-align: top;'></a>
when it's not working , click on thumbnail, here's error get...
typeerror: a[0] undefined
in jquery.fancybox.pack.js on line 15.
here's how i'm calling fancybox, maybe that's problem?
<script type="text/javascript" src="/fancybox/jquery.fancybox.pack.js?v=2.1.4"></script>
i don't care version of fancybox i' using long functionality here on page have fancybox shows when page loaded.
if have multiple images @ same page same class instead of calling above can use
$("a[rel=gallery]").fancybox({ openeffect : 'fade', // openeffect / closeeffect / nexteffect / preveffect closeeffect : 'fade', // animation effect ('elastic', 'fade' or 'none') each transition type nexteffect : 'fade', // string; default value: 'fade', 'fade', 'elastic', 'elastic' preveffect : 'fade', openspeed : '1000', // openspeed / closespeed / nextspeed / prevspeed closespeed : '1000', // time takes (in ms, or "slow", "normal", "fast") complete transition nextspeed : '1000', // integer; default value: 250 prevspeed : '1000', padding : 3 });
Comments
Post a Comment