简体   繁体   English

Lightgallery多个实例无法正常工作

[英]Lightgallery multiple instances not working

I got a couple of images that I want to open a gallery with (using lightgallery). 我有几张图片,我想打开一个画廊(使用lightgallery)。 So I looked up their documentation, and found out to use multiple instances I have to include lg-hash.js and give ids to the different galleries. 所以我查阅了他们的文档,并发现使用多个实例我必须包含lg-hash.js并将id分配给不同的库。 That is exactly what I did but the second image is not working. 这正是我所做的,但第二张图片不起作用。 It opens the lightbox but the loader just keeps spinning endlessly. 它打开了灯箱,但装载机一直在无休止地旋转。

My code: 我的代码:

<div id="hash">
    <a href="'.$fbimage.'">
        <img style="max-width:250px;" src="'.$fbimage.'">
    </a>
</div>
<div id="hash1">
    <a href="'.$block_image->{'image_intro'}.'">
        <img style="max-width:100%;" src="'.$block_image->{'image_intro'}.'">
    </a>
<div>

And the js part: 和js部分:

<script type="text/javascript">
$(document).ready(function() {
    $("#hash").lightGallery({
        hash: true,
        galleryId: 1
    });
    $('#hash1').lightGallery({
        hash: true,
        galleryId: 2
    });
});
</script>

The first one is working as it should, but the second image is not loading, and I can't close the lightgallery on the second one. 第一个是正常工作,但第二个图像没有加载,我无法关闭第二个图像。

What is going wrong? 出了什么问题? Here is a link to their documentation 这是他们文档的链接

it seems to me, as if you´re not having trouble with the JS part but with the PHP part... Could you hand out a version, which allready passed the PHP-parser? 在我看来,好像你没有遇到JS部分的麻烦,但有PHP部分...你能分发出一个版本,它已经通过了PHP解析器吗? The HTML would be helpfull here. HTML在这里会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM