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) {
|
success: function (data, status, jqXHR) {
|
||||||
|
console.log(`${NAME}: AJAX success`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const dataJson = $.parseJSON(data);
|
const dataJson = $.parseJSON(data);
|
||||||
if (typeof dataJson === 'object') {
|
if (typeof dataJson === 'object') {
|
||||||
|
console.log(`${NAME}: AJAX JSON`);
|
||||||
// Replace regions
|
// Replace regions
|
||||||
if (
|
if (
|
||||||
typeof dataJson['regions'] === 'object' &&
|
typeof dataJson['regions'] === 'object' &&
|
||||||
@ -508,6 +511,7 @@ const MetaLightboxUI = (($) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(`${NAME}: AJAX HTML`);
|
||||||
const $wrap = $(
|
const $wrap = $(
|
||||||
'<div class="meta-lightbox-ajax" />',
|
'<div class="meta-lightbox-ajax" />',
|
||||||
);
|
);
|
||||||
@ -616,6 +620,18 @@ const MetaLightboxUI = (($) => {
|
|||||||
const ui = this;
|
const ui = this;
|
||||||
|
|
||||||
ui.$content.removeClass('meta-lightbox-loading');
|
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(() => {
|
setTimeout(() => {
|
||||||
$W.trigger('meta-lightbox-loaded');
|
$W.trigger('meta-lightbox-loaded');
|
||||||
}, 1); // For CSS transitions
|
}, 1); // For CSS transitions
|
||||||
|
Loading…
Reference in New Issue
Block a user