javascriptjqueryfunctionlightgallery

how to call js function in lightgallery onCloseAfter.lg method?


i m using the lightgallery jquery plugin from https://sachinchoolur.github.io/lightGallery/

so the lightgallery is working properly. In lightgallery there is a method onCloseAfter which means Executes immediately once lightgallery is closed

Here is the code

var $lg = $('.lightgallery');
        $lg.on("onCloseAfter.lg", function() {
         alert('onCloseAfter : Executes immediately once Colorbox is closed;');
         Test();
         
                        });

simple js function

function Test(){
 alert("hello")
}

Testfunction trigger once when the lightgallery is closed how to call this function everytime when the lightgallery is closed?

Any help would be appreciated and thanks in advance


Solution

  • According to the documentation of lightGallery this shoud work

    var $lg = $('#lightgallery');
    
    $lg.lightGallery();
    
    // Fired immediately once lightgallery is closed.
    $lg.on('onCloseAfter.lg', function (event) {
        Test();
    });
    function Test() {
        alert("hello")
    }