简体   繁体   English

大型弹出窗口无法在shopify中使用

[英]magnific popup not working In shopify

I am working on custom magnific popup with shopify site.In my header.liquid file am calling the magnific popup content. 我正在与shopify网站一起自定义放大弹出窗口。在我的header.liquid文件中,正在调用放大弹出窗口内容。

<button id="open-popup" >Open popup</button>
<div id="my-popup" class="mfp-hide">
  popup  content here.
</div>

Here i have added the script in theme.js.liquid 在这里,我已在theme.js.liquid中添加了脚本

$('#open-popup').magnificPopup({
  items: [
    {
      src: '#my-popup',
      type: 'inline'
    }
  ],
  gallery: {
    enabled: true
  },
  type: 'image'
});

But It shows the following error 但是它显示以下错误

TypeError: $(...).magnificPopup is not a function

If anyone please tell me if am i miss something like js library files . 如果有人请告诉我我是否想念js库文件之类的东西

Thanks in advance. 提前致谢。

I am found the actual problem for this issue.Some of the themes having default magnific pop-up library in theme.js.liquid file. 我发现了这个问题的实际问题。一些主题在theme.js.liquid文件中具有默认的放大弹出库。

My new theme brooklyn was having magnific pop-up library already.So it was working fine now. 我的新主题布鲁克林已经有了宏伟的弹出库,因此现在可以正常使用了。

So check with theme.js.liquid file having magnific popup library present or not. 因此,请检查theme.js.liquid文件中是否存在大型弹出库。

are you sure that jQuery is included? 您确定包含jQuery吗? if so, is it imported before magnificPopup? 如果是这样,它是在magnificPopup之前导入的吗?

I had a similar issue even though the magnificPopup code was included in my theme.js. 即使在theme.js中包含了magnificPopup代码,我也遇到了类似的问题。

Don't ask me why - after wrapping the magnificPopup call in the window.onload it started working. 不要问我为什么-将magnificPopup调用包装在window.onload中之后,它开始工作。

<script>
window.onload = function() {

  $('.open-popup').magnificPopup({
    type:'inline',
    midClick: true
  });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM