Skip to content

Custom jquery code not working inside the popup box #438

Answered by gingerchew
r-interactive asked this question in Q&A
Discussion options

You must be logged in to vote

It sounds like you're using the inline slide. The thing to remember about how GLightbox works, the HTML that is being used for inline slides isn't used. It is copied.
So when the page loads and you use $('.test-list-1 li') it only sees the one on the page.

When you open the lightbox, it copies that HTML and inserts that into the slide.

There are a few solutions to this problem, the one I would suggest is using the events that are offered by GLightbox.

const lightbox = GLightbox();

lightbox.on('slide_load', () => {
  // set up your cycle function loop
})

Since we're only running the function after the lightbox is open and loaded, your snippet will see the items in the slide.

Things to loo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gingerchew
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants