dbrekalo / simpleLightbox

SimpleLightbox is lightweight and responsive lightbox library with no dependencies. Display images, galleries, videos or custom content and control your lightbox with easy to use api.
http://dbrekalo.github.io/simpleLightbox/
MIT License
263 stars 76 forks source link

Multiple occurence of lightbox on one page #7

Closed vjer514 closed 6 years ago

vjer514 commented 6 years ago

I am using the 'showGalleryFromArray' approach, I am using an image instead of words as the button and it works great, but I need to have multiple clickable "buttons" on one page, each with it's own array of images. The problem is, when you click on the first one, both slide shows open - both the one you clicked on and the other one on the page. Is there a way to make each 'showGalleryFromArray' unique so that it will only open when it is clicked. I tried using role="button1", and role="button2" but that didn't work

http://thefreshflowermarketevents.com/sandbox/wedding-gallery.html

dbrekalo commented 6 years ago

On site provided you are binding click handler twice to same selector - you should alter your selectors (notice added gallery1 and gallery2 classes in click handlers, make sure your html has those classes applied as well)

$('.showGalleryFromArray.gallery1').on('click', function() {
        $.SimpleLightbox.open({
            items: [...]
        });
    });
$('.showGalleryFromArray.gallery2').on('click', function() {
        $.SimpleLightbox.open({
            items: [...]
        });
    });
vjer514 commented 6 years ago

Perfect. Thank you so much!

Vicki S Jones Willow Circle Web Services vicki@willowcirclewebservices.com

On Jul 9, 2018, at 4:09 AM, Damir Brekalo notifications@github.com wrote:

On site provided you are binding click handler twice to same selector - you should alter your selectors (notice added gallery1 and gallery2 classes)

$('.showGalleryFromArray.gallery1').on('click', function() { $.SimpleLightbox.open({ items: [...] }); }); $('.showGalleryFromArray.gallery2').on('click', function() { $.SimpleLightbox.open({ items: [...] }); }); — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dbrekalo/simpleLightbox/issues/7#issuecomment-403429272, or mute the thread https://github.com/notifications/unsubscribe-auth/AmawUQ8gbUe2c3TwJOY5OeLjh4VDFNOSks5uEyvbgaJpZM4Uo9eH.