mirror of
https://github.com/a2nt/meta-lightbox.git
synced 2024-10-22 17:05:53 +02:00
Call new lightbox from the AJAX window content
This commit is contained in:
parent
2054cd3277
commit
48e3cc9a13
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user