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

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

我正在使用来自 https://sachinchoolur.github.io/lightGallery/

lightgallery jquery 插件

所以 lightgallery 工作正常。在 lightgallery 中有一个方法 onCloseAfter 这意味着 Executes immediately once lightgallery is closed

这是代码

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

简单js功能

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

Test函数在 lightgallery 关闭时触发一次 如何在 lightgallery 关闭时每次调用此 function

如有任何帮助,我们将不胜感激,并提前致谢

根据 lightGallery 的文档,这应该有效

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

$lg.lightGallery();

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