简体   繁体   English

如何在lightgallery onCloseAfter.lg方法中调用js function?

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

im using the lightgallery jquery plugin from https://sachinchoolur.github.io/lightGallery/我正在使用来自https://sachinchoolur.github.io/lightGallery/lightgallery jquery 插件

so the lightgallery is working properly.所以lightgallery工作正常。 In lightgallery there is a method onCloseAfter which means Executes immediately once lightgallery is closedlightgallery中有一个方法onCloseAfter这意味着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简单的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?lightgallery关闭时Test function 触发一次 每次lightgallery廊关闭时如何调用此function

Any help would be appreciated and thanks in advance任何帮助将不胜感激,并提前感谢

According to the documentation of lightGallery this shoud work根据lightGallery的文档,这应该工作

var $lg = $('#lightgallery');

$lg.lightGallery();

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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