biati-digital / glightbox

Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes
MIT License
2.01k stars 226 forks source link

Add support for async content #442

Closed massimo-cassandro closed 11 months ago

massimo-cassandro commented 1 year ago

It seems that glightbox is only active for loaded content, it would be helpful if it could be configured to work on asynchronous loaded content as well (using event delegation?).

davidblanco-m commented 1 year ago

x2

gingerchew commented 12 months ago

@massimo-cassandro can you give an example of what you mean? async content is a bit too vague for me to really understand what you're looking for.

massimo-cassandro commented 11 months ago

If you have content loaded by Ajax and this content has some glightbox elements, you need to initialize glightbox every time the content changes.

It would be very helpful if there was a way to delegate glightbox to the container, making it always active whatever content is loaded.

gingerchew commented 11 months ago

I see, there's an example of how to do that in the documentation here you'll need to scroll to the end of the code example. Gist of it is when the ajax call is complete, insert the slides using insertSlide

massimo-cassandro commented 11 months ago

OK, I missed it Thanks