The site has a page with endless scrolling that downloads the content. There is also a gallery on the page, implemented with the lightgallery plugin. When loading a page the plugin works, but after loading new content, the plugin stops working only in the content that is loaded.
How do I place lightGallery
plugin code correctly so that it loads js every time? And did I add this code correctly?
Script plugin
$(document).ready(function() {
function createLightGallery() {
$('.gallery-img').lightGallery({
thumbnail: true,
width: '1104px',
height: '80vh',
selector: '.item-image-gallery'
});
}
createLightGallery();
})
js code success
success: function(obj) {
send = true;
$article_list.append(obj);
const players = Array.from(document.querySelectorAll('#videoPlay')).map(p => new Plyr(p));
const plyrs = Array.from(document.querySelectorAll('#plyrVideo')).map(plyrs => new Plyr(plyrs));
page.getAsideHtml(_url_aside);
page.scrollPage();
//js plugin
createLightGallery();
},
This is the kind of mistake
script.js:7119 Uncaught ReferenceError: createLightGallery is not defined
at Object.success (script.js:7119)
at c (script.js:2)
at Object.fireWith [as resolveWith] (script.js:2)
at l (script.js:2)
at XMLHttpRequest.<anonymous> (script.js:2)