How can I programmatically close any open lightbox ?
I need close the lightbox when the ajax request is finished, any way ?
答案 0 :(得分:3)
在AJAX调用完成时触发事件,让灯箱侦听事件并在看到事件时自行关闭。
// When your AJAX call completes
var event = new CustomEvent('someEventOrSomething');
document.dispatchEvent(event);
// Your lightbox stuff
$(whateverYoureLightboxing).ekkoLightbox({
onShown: function() {
var lightbox = this;
document.addEventListener('someEventOrSomething', function () {
lightbox.close();
});
}
});