Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
AJAX compatibility with lightGallery

I am using lightGallery (1.4.0) to display images. Images come in JSON format with Ajax requests. But when I click on the images I can't view them with lightGallery. Can you tell me where am I missing something?

Settings:

var gallery = function () {
        var gallery = document.querySelectorAll('.gallery');
        if (gallery.length) {
            for (var i = 0; i < gallery.length; i++) {
                lightGallery(gallery[i], {
                    selector: '.gallery-item',
                    download: false,
                    animateThumb: false,
                    videojs: true,
                    youtubePlayerParams: {
                        modestbranding: 1,
                        showinfo: 0,
                        rel: 0
                    },
                    vimeoPlayerParams: {
                        byline: 0,
                        portrait: 0,
                        color: '766df4'
                    }
                });
            }
        }
    }();

DIVs generated with ajax result:

if (itemData.item.phl) {
    for (let phlX = 0; phlX < itemData.item.phl.length; phlX++) {
        document.getElementById('item_photos_larges').innerHTML += '<div class="col-sm-6 mb-grid-gutter"><a class="gallery-item rounded-1" href="' + itemData.item.phl[phlX].url + '"><img alt="' + translate_photo + ' ' + [phlX] + '" src="' + itemData.item.phl[phlX].url + '"></a></div>';
    }
}

Thank you.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!