【发布时间】:2018-12-12 03:10:14
【问题描述】:
我需要 Magnific-popup 仅绑定到 HTML 中的某些链接。因此,当单击一个链接时,它将链接到另一个网站。如果单击其他链接,它将放大图像。
现在被点击的链接没有包含在弹出窗口初始化的图像中。
这是 HTML
<div class="field__item">
<div class="mfp-field mfp-separate-item">
<a href="path-to-origin-image">
<!-- This link is being added to the popup and works correctly-->
<img class="mfp-thumbnail" src="img-url" />
</a>
</div>
<div class="field--name-field-url">
<!-- This link is being added to the popup and should be ignored -->
<a href="https://google.com">Google</a>
</div>
</div>
这是jquery
$(context).find('.field--name-field-gallery-items').once('mfp-processed').each( function() {
$(this).magnificPopup({
delegate: 'a',
type: 'image',
gallery: {
enabled: true
},
image: {
titleSrc: function (item) {
return item.img.attr('alt') || '';
}
}
});
});
$(context).find('.field--name-field-gallery-items .field--name-field-url a').each().unbind('click');
如何阻止 magnificPopup 绑定到第二个链接?
【问题讨论】:
标签: magnific-popup