lightbox.loadAndOpen(0) opens empty lightbox #2020
-
Hello there. I made a photoswipe lightbox which is working fine and opens when I click on the thumbnails. But when I try to open it with the loadAndOpen(0) method (I want to open it on page load), the opened lightbox stays empty, no images inside (the pswp__container contains 3empty pswp__item-classed divs). Photoswipe Version 5.3.6 Any help? |
Beta Was this translation helpful? Give feedback.
Answered by
dimsemenov
Mar 1, 2023
Replies: 1 comment 1 reply
-
If you use lightbox.loadAndOpen(0, {
gallery: document.querySelector('.your-gallery-selector');
}); or just trigger click on the element that you wish to open |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
emollini
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use
gallery
andchildren
options,loadAndOpen
doesn't know which exactly gallery to use, since there might be multiple galleries on a page. Instead you can do something like:or just trigger click on the element that you wish to open