sachinchoolur / lightGallery

A customizable, modular, responsive, lightbox gallery plugin.
https://www.lightgalleryjs.com/
Other
6.53k stars 1.29k forks source link

Images loaded by ajax #129

Closed rafasegat closed 9 years ago

rafasegat commented 9 years ago

Hey,

I have a issue. My gallery and LightGallery are working perfectly but I have a Load More button that load more photos using ajax. So I call LightGallery function again and does not work well.

Example http://instagramwordpress.rafsegat.com/

Thanks so much and beautiful plugin BTW

rafasegat commented 9 years ago

Any answer?

sachinchoolur commented 9 years ago

Hi, You have to destroy the plugin and re-initiate it after clicking on load more button.


var gallery = $('#gallery').lightGallery();

$('#load-more').on('click', function() {
    gallery.destroy();
    gallery = $('#gallery').lightGallery();
});
rafasegat commented 9 years ago

Thanks so much sachinchoolur!

That was a huge issue on my plugin and now its working fine.

I`ll put considerations and show LightGallery plugin on my codecanyon plugin page

Thanks so much! Raf

awplige commented 6 years ago

Finally I got resolved my problem in ajax load more new images into lightgallery:

var $lg = jQuery('div#animated-thumbnials'); 
$lg.lightGallery(); 
$lg.data('lightGallery').destroy(true);         
$lg.lightGallery();

Thanks, guys for the destroy function hint.