jquery - Fancybox gallery with images in different places -


i have (html) page image gallery (all images together) , 1 separate image.

i put images image gallery in a

<div id="imagegallery"> 

i put separate image in a

<div id="separateimage"> 

and have javascript

$('#imagegallery a').fancybox(); $('#separateimage a').fancybox(); 

fancybox works fine on both, image gallery , separate image. can cycle through image gallery, however, separate image not part of cycle. how can make cycles through images: image gallery , separate image?

i tried adding

rel="gallery" 

to anchors explained @ https://www.inkling.com/read/javascript-jquery-david-sawyer-mcfarland-2nd/chapter-7/advanced-gallery-with-jquery

but apparently works if images in same div (id)!?

the issue binding fancybox 2 different selectors :

$('#imagegallery a') , $('#separateimage a') in order make gallery, elements whether within same div or not, need use same selector (fancybox v2.x)

so without having hard-code manually each element of each separated div, :

$("#imagegallery a, #separateimage a")     .addclass("fancybox")     .attr("rel", "gallery")     .fancybox({        //api options        padding: 8 // example     });  

now elements regardless position share same class , rel attribute.

see jsfiddle


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -