Topic: LightBox loaded with Ajax - problem
vizmedia pro asked 7 years ago
ilivingston premium answered 4 years 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 premium commented 4 years 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'); }
Adrian Sawicki free answered 7 years ago
vizmedia pro answered 7 years ago
Adrian Sawicki free answered 7 years ago
Daniel pro answered 7 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No