简体   繁体   中英

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

im 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")
}

Test function 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

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")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM