我正在尝试在Justified Gallery中使用Magnific Popup,但遇到了麻烦。它似乎没有拾取我希望它处理的锚标记,并且单击图像最终会直接进入 href 位置。
我知道它在页面上工作,因为如果我手写一些香草标记,它工作正常:
<a class="gallery-image" href="http://localpath/imagelarge.jpg">
<img src="http://localpath/imagethumb.jpg">
</a>
但是,由于我使用的是 Justified Gallery,生成的标记并不完全相同:
<div class="justifiedGallery" id="gallery">
<div class="jg-row" style="height: 128px; margin-bottom: 1px;">
<div class="jg-image" style="left: 0px;">
<a class="gallery-image" href="http://localpath/imagelarge.jpg">
<img style="width: 192px; height: 128px; display: inline; opacity: 1;" alt="undefined" src="http://localpath/imagethumb.jpg">
</a>
</div>
</div>
</div>
这是我用于工作示例和无效示例的 JavaScript:
<script type="text/javascript">
$(document).ready(function () {
$("#gallery").justifiedGallery({
'usedSuffix': 'lt240',
'justifyLastRow': false,
'rowHeight': 120,
'fixedHeight': false,
'captions': false,
'margins': 1
});
$('.gallery-image').magnificPopup({
type: 'image'
});
});
</script>
我确实必须调整 Justified Gallery 才能添加 gallery-image 类,但其他一切都是库存。
我在想有什么矛盾的,但我似乎无法找到它。
有人用过这两个吗?我初始化 Magnific 的方式有问题吗?