fancyapps/fancyBox — Issue #65: Creating a dynamic gallery...
Author: DanielMenjivar
Created: 2011-12-16 21:05:27+00:00
State: open

In the previous version of fancyBox (1.3.4) I used to use this:

```javascript
$('.dm-photo a').each(function () {
$(this).attr('rel','gallery').fancybox({
'type' : 'image',
'href' : $('img',this).attr('src').replace('_thumb','')
});
});
```

And now in the new version (2.0.4) I've modified it to this:

```javascript
$('.dm-photo a').each(function() {
$(this).data('fancybox-group','dm').fancybox({
type : 'image',
href : $('img',this).attr('src').replace('_thumb','')
});
});
```

In the old version of fancyBox, this would allow all images to open up in a gallery (by setting the rel attribute to 'gallery') but in the new version, even though I've looped through each anchor element to set the data-fancybox-group attribute, only one image shows up (not a gallery).

It seems that whenever you include a href in the options, it only opens one image at a time and ignores the rel or custom data attributes. I'm sure there's probably a better way to do this (maybe using callbacks?) but I'm not sure how...