我使用jquery 1.11.3和bower安装的lightgallery(https://github.com/sachinchoolur/lightGallery)的新版本1.2进行了以下设置。我尝试了几种带有和不带选择器的变体,例如以下,但画廊总是打开(确定),但显示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脚本中?
答案 0 :(得分:1)
选择器对象应具有data-src/href
属性以及图片/视频的大版本网址。因此,您只需将选择器值更改为li a
$('.multiSRC ul').lightGallery({
selector: "li a"
});
这是工作演示。 http://jsfiddle.net/amL2Lpqa/1/