JS error on Lightbox


Topic: JS error on Lightbox

squarepegsys asked 6 years ago

I get a javascript error when making a basic lightbox:

mdb.js:6501 Uncaught TypeError: Cannot read property 'firstChild' of undefined
    at Object.getChildByClass (mdb.js:6501)
    at a.init (mdb.js:6798)
    at openPhotoSwipe (mdb.js:8049)
    at HTMLDivElement.onThumbnailsClick (mdb.js:7957)

I made a snippet from the example I was looking at on the Lightbox page and got a similar error. See: https://mdbootstrap.com/snippets/jquery/temp/629709?action=prism_export


Sebastian Kaczmarek staff pro premium answered 6 years ago

Hi, please remember to initialize the lightbox. You need to add this code to the JS section:

$(function () {
$("#mdb-lightbox-ui").load("mdb-addons/mdb-lightbox-ui.html");
});

Hope it helps


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.7.7
  • Device: MacOs
  • Browser: Chrome
  • OS: MacOs
  • Provided sample code: No
  • Provided link: Yes