单击外部弹出窗口时,Magnific模式关闭

时间:2017-03-16 07:19:31

标签: javascript magnific-popup

单击弹出窗口时,Magnific弹出窗口关闭,模态设置为true。

      $(document).ready(function() {
    $.magnificPopup.open({
      items: {
        src: '<div class="white-popup">Our terms and conditions have changed. Please review them: <p><br><a class="popup-modal-dismiss" href="#">Got it</a></p></div>',
        type: 'inline',
        preloader: false,
        modal: true
      }
    });
    $(document).on('click', '.popup-modal-dismiss', function(e) {
      e.preventDefault();
      $.magnificPopup.close();
    });   
  });

http://codepen.io/anon/pen/YZrRyw

this post报告类似问题,但我在笔中使用最新版本

1 个答案:

答案 0 :(得分:2)

你犯了一个小错误,配置不应该在items{...}

之内
$(document).ready(function() {
  $.magnificPopup.open({
    items: {
      src: '<div class="white-popup">Our terms and conditions have changed. Please review them: <p><br><a class="popup-modal-dismiss" href="#">Got it</a></p></div>',
      type: 'inline',
    },
    modal: true,
    preloader: false,
  });

});

这是更新的代码集:http://codepen.io/anon/pen/EWwObY