metafizzy / flickity-docs

:memo: documentation for Flickity
28 stars 8 forks source link

Multiple galleries, next triggers on all of them #15

Closed sanschaise closed 9 years ago

sanschaise commented 9 years ago

If you have multiple galleries

var $gallery = $('.gallery').flickity({ prevNextButtons: false, pageDots: true, contain:true,

});

$('.gallery-item').on( 'click', function() { $gallery.flickity( 'next', true ); });

will trigger on all the galleries on a page...

Is there a way to trigger it on $(this).parent() ?

desandro commented 9 years ago

Yes, try:

$('.gallery-item').on( 'click', function() {
  $(this).parents('.gallery').flickity( 'next', true );
});
sanschaise commented 9 years ago

Perfect!! Thank you!