Skip to content

Instantly share code, notes, and snippets.

@robertbiswas
Created June 12, 2024 20:43
Show Gist options
  • Save robertbiswas/01216d085ea7f859eb9041b63967501f to your computer and use it in GitHub Desktop.
Save robertbiswas/01216d085ea7f859eb9041b63967501f to your computer and use it in GitHub Desktop.
Glightbox Opens one at a time fix
const lightbox = GLightbox()
const allLightboxTriggers = document.querySelectorAll('.lightbox-trigger')
if (allLightboxTriggers) {
allLightboxTriggers.forEach(function(trigger) {
trigger.addEventListener('click', function(e) {
e.preventDefault()
let targetHref = this.getAttribute('href')
lightbox.setElements([{'href': targetHref}])
lightbox.open()
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment