electerious / basicLightbox

The lightest lightbox ever made.
https://basiclightbox.electerious.com
MIT License
557 stars 55 forks source link

closing an instance of a lightbox with an independent button #41

Closed halukkaramete closed 1 year ago

halukkaramete commented 1 year ago

I would like this button

electerious commented 1 year ago

I think that's possible somehow, but the question is more about the communication between a site and an iframe, not about basicLightbox. The API should provide everything you need once you got the communication working.

brycekirkcalm commented 1 year ago

I did it this way (more or less):


let lightboxInstance = basicLightbox.create(lightboxHtml)
lightboxInstance.show()
let closeModalBtn = document.querySelector('.modal-close') // This is a button that I've included in lightboxHtml
closeModalBtn.addEventListener('click', () => lightboxInstance.close())