0

我使用 jquery 1.11.3 和 bower 安装的新版本 1.2 的 lightgallery ( https://github.com/sachinchoolur/lightGallery ) 进行了以下设置。我尝试了几个带有和不带有选择器的变体,例如以下,但始终打开图库(好的),但在 JS 错误和旋转符号下方显示。那有什么问题?

// include the js and css ...
<script>
    (function ($) {
        $(document).ready(function () {
            $('.multiSRC ul').lightGallery({
                selector: "li"
            }); 
        });
    })(jQuery);
</script>

<div class="ce_rsce_cl_gallery first block">
    <h2>Vestibulum mollis.</h2>
    <div class="field singleSRC">
        <div class="inner">
            <figure class="image_container">
                <img src="assets/images/d/unsplash_528e297be299b_1_thumb-224ccacd.jpg" alt="" class="" height="250" width="250">
            </figure>
        </div>
    </div>

    <div class="field multiSRC">
        <div class="inner">
            <ul>
                <li>
                    <figure class="image_container">
                        <a href="files/upload/photo-1426174840074-541ae41efdb9.jpg" data-lightbox="lb208875">
                            <img src="assets/images/2/photo-1426174840074-541ae41efdb9-71ccd312.jpg" alt="" class="" height="125" width="125">
                        </a>
                    </figure>
                </li>
                <li>
                    <figure class="image_container">
                        <a href="files/upload/photo-1425934398893-310a009a77f9.jpg" data-lightbox="lb208875">
                            <img src="assets/images/4/photo-1425934398893-310a009a77f9-ba3b2cd4.jpg" alt="" class="" height="125" width="125">
                        </a>
                    </figure>
                </li>
            </ul>
        </div>
    </div>
</div>

发生此错误:

21:04:43.287 TypeError: src is undefined1 lightgallery.js:393:12

这是

var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9self\-]+)/i);

我做错了吗?还是 lightgallery 脚本中隐藏了一些错误?

4

1 回答 1

1

选择器对象应该具有data-src/href您的图像/视频的大版本 url 的属性。所以您可以将选择器值更改为li a

$('.multiSRC ul').lightGallery({
    selector: "li a"
});

这是工作演示。http://jsfiddle.net/amL2Lpqa/1/

于 2015-08-28T06:28:58.333 回答