[英]lightGallery in dynamic mode: incorrect image is loading when clicked
When I set up my lightGallery dynamically, and use 'index' to target which image should open when a link is clicked, the wrong image shows up unless it's the very first click. 当我动态设置lightGallery并使用“索引”定位单击链接时应打开的图像时,除非第一次单击,否则将显示错误的图像。
In other words, if you initially click on a thumbnail image, you'll see the correct larger image being selected in the gallery that pops up. 换句话说,如果您最初单击缩略图,则会在弹出的图库中看到选择的正确的较大图像。 However, if you then close that image, and then click on a different thumbnail image, you will see the wrong image being enlarged (it's grabbing the first one that you had clicked on). 但是,如果您随后关闭该图像,然后单击其他缩略图图像,则会看到放大了错误的图像(它抓住了您单击的第一个图像)。 I figure that this must be something to do with the 'index' functionality getting stuck after the first click? 我认为这与“索引”功能在第一次单击后卡住有关吗?
I've created a jsfiddle that demonstrates the issue (apologies for all the nested DIVs etc., however I'm confident that those are not the cause): http://jsfiddle.net/fcdeLd03/18/ 我创建了一个jsfiddle来演示该问题(为所有嵌套的DIV等致歉,但是我确信这些不是原因): http : //jsfiddle.net/fcdeLd03/18/
Anyone have any ideas? 有人有想法么?
This is my Javascript code to initiate the lightGallery: 这是我启动lightGallery的Javascript代码:
$(".nodoubt").on('click', function(){
var slideID = $(this).attr('data-slide');
$("#lightgallery").lightGallery({
download: false,
dynamic: true,
dynamicEl: [{
"src": 'http://sachinchoolur.github.io/lightGallery/static/img/1.jpg',
'thumb': 'http://sachinchoolur.github.io/lightGallery/static/img/thumb-1.jpg',
'subHtml': 'Photo 1 by <a href="http://www.example.com" target="_blank">Photographer Name</a><br />More caption text.<br />Even more caption text.'
},{
"src": 'http://sachinchoolur.github.io/lightGallery/static/img/2.jpg',
'thumb': 'http://sachinchoolur.github.io/lightGallery/static/img/thumb-2.jpg',
'subHtml': 'Photo 2 by <a href="http://www.example.com" target="_blank">Photographer Name</a><br />More caption text.<br />Even more caption text.'
},{
"src": 'http://sachinchoolur.github.io/lightGallery/static/img/3.jpg',
'thumb': 'http://sachinchoolur.github.io/lightGallery/static/img/thumb-3.jpg',
'subHtml': 'Photo 3 by <a href="http://www.example.com" target="_blank">Photographer Name</a><br />More caption text.<br />Even more caption text.'
},],
index : slideID
});
});
/* for me helped */
<script type="text/javascript">
$(document).ready(function() {
$( "#pilt" ).click(function() {
var lGallery = $(this).lightGallery({
dynamic: true,
dynamicEl: [{___data___}]
});
/* open gallery on right image */
/* lightGallery parameter 'index' does not work */
lGallery.data('lightGallery').index = currentPage; /* page index you want to open */
})
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.