Lightgallery: Reload gallery with new set of images

Created on 5 Jan 2017  路  4Comments  路  Source: sachinchoolur/lightGallery

Hi,

I want to be able to do this. I have a gallery with all images and on click of a button or link, I want to show only portraits or landscapes. I'm changing the array that is bound to lightgallery but how do i refresh/ reload gallery with new set of images?

Thanks!!

Most helpful comment

Hi @anantheswarg881 ,

You need to destroy and re-initiate lightGallery.
Demo: http://sachinchoolur.github.io/lightGallery/demos/methods.html

Let me know if you need any further explanations

All 4 comments

Hi @anantheswarg881 ,

You need to destroy and re-initiate lightGallery.
Demo: http://sachinchoolur.github.io/lightGallery/demos/methods.html

Let me know if you need any further explanations

Hi Sachin,

Thanks for your reply. The link you gave me helped. But not fully solved.

I'm binding the images of the gallery using an angular js controller. When I change the array, destroy gallery and instantiate it again, the gallery changes but when I click on an item, the older gallery with full set of images is shown in the pop up modal. so the thumbnails still contained the older data.
The following code changed the gallery data but not thumbnails. Is there a way to solve it?
$scope.activeImages = $scope.portfolioImages;

    var gallery = $('#lightgallery');
    gallery.data('lightGallery').destroy(true);
    gallery.lightGallery({
        thumbnail: true
    });

I think the gallery is not properly destroyed. It is difficult to debug without seeing the actual code. If you can send me an isolated(jsfiddle, plunker) demo, I'll fix the issue and send you back.

Please reopen if the issue persists

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kachurun picture kachurun  路  4Comments

andrew--r picture andrew--r  路  3Comments

KomalDivate picture KomalDivate  路  4Comments

miedzikd picture miedzikd  路  6Comments

hokutonanto picture hokutonanto  路  7Comments