Jquery Popup插件在单击任何位置时都会关闭

Jquery Popup plugin closes when clicked anywhere

本文关键字:位置 任何 Popup 插件 单击 Jquery      更新时间:2023-09-26

当我点击弹出窗口上的任何位置时,它都会关闭,但它不应该这样做,它应该只在我点击X按钮时关闭。我正在使用放大弹出插件。作者的演示效果很好,但当我在网站上实现插件时,它不像演示那样工作。这给我带来了问题,因为如果我试图点击弹出窗口中的任何链接,它会关闭弹出窗口,而不是打开链接。

你知道是什么原因吗?以下代码:

<script type="text/javascript">
      $(document).ready(function() {
        $('.simple-ajax-popup-align-top').magnificPopup({
          type: 'ajax',
          alignTop: true,
          overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
        });
        $('.simple-ajax-popup').magnificPopup({
          type: 'ajax'
        });
      });
    </script>
<a class="simple-ajax-popup-align-top ajax-gal"  href="test.html">test</a>

作者的演示网站:http://dimsemenov.com/plugins/magnific-popup/

有几个选项可以控制关闭行为。

closeOnContentClick: false, // if true, closes the popup if you click on it
closeOnBgClick: true, // if true, closes the popup if you click on the grey stuff around it
showCloseBtn: false, //if true, shows a closing button top right.

您可以在此处了解有关这些选项的更多信息:http://dimsemenov.com/plugins/magnific-popup/documentation.html#options

既然你是个懒惰的程序员:

<script type="text/javascript">
  $(document).ready(function() {
    $('.simple-ajax-popup-align-top').magnificPopup({
      type: 'ajax',
      alignTop: true,
      closeOnContentClick: false,
      closeOnBgClick: true,
      showCloseBtn: false,
      overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
    });
    $('.simple-ajax-popup').magnificPopup({
      type: 'ajax',
      closeOnContentClick: false,
      closeOnBgClick: true,
      showCloseBtn: false
    });
  });
</script>
相关文章: