Topic: LightBox loaded with Ajax - problem
Daniel
pro answered 4 years ago
Adrian Sawicki
answered 4 years ago
vizmedia
pro answered 4 years ago
Adrian Sawicki
answered 4 years ago
ilivingston
pro premium answered 8 months ago
I'm struggling with this a bit also. For example, I have a set of cached views stored in a JS object, and use pagination to swap out the views. Each cached view contains a carousel of images with an associated lightbox. Upon injecting the view into the view container, the lightbox is not initialized.
The lightbox does work on static views.
ilivingston pro premium commented 8 months ago
For what its worth; including the lightbox.js file and calling initPhotoSwipeFromDOM('.mdb-lightbox'); after the dynamic load seems to have resolved the issue. A bit deeper that I would like, and also not intuitive. I would have thought a recalling $("#mdb-lightbox-ui").load("/Content/mdb-addons/mdb-lightbox-ui.html"); should have done the trick.
my working code now looks like:
$(function() { ... $("#mdb-lightbox-ui").load("/Content/mdb-addons/mdb-lightbox-ui.html"); initPhotoSwipeFromDOM('.mdb-lightbox'); }
Answered
- User: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No