Topic: Ligthbox created with javascript
1robin priority asked 11 months ago
Expected behavior When I click a button, an image with lightbox has to be appended to a div and ligthbox works
Actual behavior When I click a button, an image with lightbox has to be appended to a div but ligthbox doesnt work
Resources (screenshots, code snippets etc.) https://mdbootstrap.com/snippets/standard/robin_reichenbach/5801831
1robin priority answered 11 months ago
I want to have multiple buttons, when I click in each button a different image must be displayed in a div, each image must be in a lightbox
Grzegorz Bujański staff commented 11 months ago
If you add a component dynamically, you must init it. Check out this snippet: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/5819080
1robin priority commented 11 months ago
The URL is wrong... I get 404 error
Grzegorz Bujański staff commented 11 months ago
Sorry about that. Check now.
Kamila Pieńkowska staff answered 11 months ago
Can you describe what you want to achieve?
This is not the way to initiate Lightbox. You either have it present on the page from the beginning or append it later and initialize it with JS.
Also, you cannot append new images to the existing lightbox. If you want to add a new image you need to dispose of lightbox instance, add a new image and initiate a new Lightbox instance using JS.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 7.0.0
- Device: laptop
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: Yes