1

I successfully implemented my Magnific Popup plugin, binding it to the gallery element (a div containing a set of img elements wrapped up in a elements). But I also want the lightbox to appear when clicking on a separate "see gallery" button.

I can't see anywhere how to achieve that in the documentation. Is it even possible?

drake035
  • 3,955
  • 41
  • 119
  • 229

2 Answers2

3

You can just trigger click event via JS, e.g.:

$('.popup-gallery').find('a').eq(0).trigger('click');
Dmitry Semenov
  • 4,566
  • 2
  • 36
  • 39
  • Just what I need, thanks! Any idea why the scroll position of the page changes (to about one screen upwards) when opening the gallery this way, while it remains unchanged by opening it by clicking on one of the pictures? – drake035 Mar 09 '15 at 21:26
  • 1
    Hard to tell without link to the page with issue. Do parent elements have any kind of links with #hashes? – Dmitry Semenov Mar 12 '15 at 21:51
1

Basically, when the "see gallery" button is clicked you want to trigger the click event on the element that normally opens the popup, so that the popup will open. See this question for some good ways of doing this.

Community
  • 1
  • 1
firefoxuser_1
  • 1,793
  • 13
  • 22