Using FancyBox on dynamically created galleries

252 views
Skip to first unread message

Ater Deus

unread,
Feb 13, 2012, 5:28:25 AM2/13/12
to fancybox
I got a gallery page, where i dynamically change galleries. Now
FanxyBox works only on static one. How to delegate 'click' event to
others?

Thx for help!

Ater Deus

unread,
Feb 13, 2012, 6:07:47 AM2/13/12
to fancybox
Sry, found this one. But now a new problem:

When i call FancyBox with
$(document).ready(function() {
$(document).delegate(".gallery", "click", function(event){
event.preventDefault();
$.fancybox(this,{
// fancybox options
}); // closes fancybox
}); // closes delegate
}); // closes ready

Images are not in galleries. So if i click picture, i can't change it
to next or prev. Where should i put .attr('rel','mygallery') ?

Ater Deus

unread,
Feb 13, 2012, 7:39:28 AM2/13/12
to fancybox
i replaced
$.fancybox(this,{
with
$('.gallery').attr('rel','mygallery').fancybox({
now it works, but i need to press on picture twice, to make it work.

Hm... talking to myself is quite effective :D

JFK

unread,
Feb 13, 2012, 2:19:26 PM2/13/12
to fancybox

Ater Deus

unread,
Feb 14, 2012, 3:40:07 AM2/14/12
to fancybox
Thx! Works fine for me!
Reply all
Reply to author
Forward
0 new messages