Call new lightbox from the AJAX window content

This commit is contained in:
Tony Air 2020-12-03 16:01:47 +07:00
parent 2054cd3277
commit 48e3cc9a13
1 changed files with 16 additions and 0 deletions

View File

@ -414,9 +414,12 @@ const MetaLightboxUI = (($) => {
}
},
success: function (data, status, jqXHR) {
console.log(`${NAME}: AJAX success`);
try {
const dataJson = $.parseJSON(data);
if (typeof dataJson === 'object') {
console.log(`${NAME}: AJAX JSON`);
// Replace regions
if (
typeof dataJson['regions'] === 'object' &&
@ -508,6 +511,7 @@ const MetaLightboxUI = (($) => {
}
}
} catch (e) {
console.log(`${NAME}: AJAX HTML`);
const $wrap = $(
'<div class="meta-lightbox-ajax" />',
);
@ -616,6 +620,18 @@ const MetaLightboxUI = (($) => {
const ui = this;
ui.$content.removeClass('meta-lightbox-loading');
$(`.meta-lightbox-content .js${NAME},.meta-lightbox-content [data-toggle="lightbox"],.meta-lightbox-content [data-lightbox-gallery]`).on(
'click',
(e) => {
e.preventDefault();
e.stopPropagation();
const $link = $(e.currentTarget);
ui.show($link);
},
);
setTimeout(() => {
$W.trigger('meta-lightbox-loaded');
}, 1); // For CSS transitions