在ajax请求的成功区域,我添加了一个通过jQuery打开fancybox的onClick eventListener。通过data-attribute接收和传递图库的对象。
jQuery.ajax({
type: "post",
dataType: "json",
url: ajax_url,
data: data,
success: function( response ) {
poi_images = '';
if(poi_data['images'] !== undefined) {
poi_gallery_class = 'poi-gallery';
poi_images = JSON.stringify(poi_data['images']);
}
// [...]
$('.poi-gallery').on('click', function() {
gallery = $(this).attr('data-gallery');
gallery = JSON.parse(gallery);
console.log(gallery);
$.fancybox.open(
gallery, {
helpers : {
thumbs : {
width: 75,
height: 50
}
},
});
});
}
});fancybox图库打开,显示图库中正确数量的图像,但没有显示任何图像。Container仍然是空的,fancybox图像的src仍然是空的。

我哪里做错了?
发布于 2021-04-27 06:00:23
计算出图像url的键名必须命名为"src“而不是"href”。
https://stackoverflow.com/questions/67265066
复制相似问题