简体   繁体   English

宏伟的弹出窗口:使用不同的选项打开第二个弹出窗口

[英]Magnific Popup: opening second popup with different options

Using Magnific Popup is it possible to force a second popup, opened while the first one is still open, to accept new options? 使用Magnific Popup可以强制第二个弹出窗口(在第一个弹出窗口仍处于打开状态时打开)接受新选项吗? The documentation states the following: 文档指出以下内容:

"If popup is already opened - it'll just overwite the content (but old options will be kept)." “如果弹出窗口已经打开-它只会覆盖内容(但旧选项将保留)。”

I'm opening the popup using the public open() method within some JavaScript. 我正在使用某些JavaScript中的public open()方法打开弹出窗口。 The issue I have is that my first popup is modal so has no close button added to it. 我的问题是我的第一个弹出窗口是模式弹出窗口,因此没有添加关闭按钮。 The second popup shouldn't be modal but because it uses the options of the first rather than it's own, it is modal. 第二个弹出窗口不应该是模态的,但是因为它使用第一个弹出窗口的选项而不是它自己的选项,所以它是模态的。

Here's a jsFiddle with the problem: jsfiddle 这是有问题的jsFiddlejsfiddle

Here is an example: 这是一个例子:

Html HTML

<div class="popup_dialog mfp-hide" id="modal_popup">
  <p>My modal popup</p>
</div>

<div class="popup_dialog mfp-hide" id="non_modal_popup">
  <p>My non modal popup, which should have a close button.</p>
</div>

CSS CSS

.popup_dialog {
  background: none repeat scroll 0 0 #fff;
  border-radius: 3px;
  margin-left: auto;
  margin-right: auto;
  max-width: 500px;
  padding: 30px;
  position: relative;
}

.mfp-hide {
    display:none;
}

JavaScript JavaScript的

  $(document).ready(function () {
    // Open the first, modal popup
    $.magnificPopup.open({
      items: {
        src: $('#modal_popup')
      },
      type: 'inline',
      modal: true
    });

    // Open the second, non-modal popup
    setTimeout(function () {
      $.magnificPopup.open({
        items: {
          src: $('#non_modal_popup')
        },
        type: 'inline',
        modal: false,
        closeBtnInside: true
      });
    }, 2000);
  });

如果需要使用其他选项,则需要在打开第二个弹出窗口之前调用$.magnificPopup.close()方法。

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

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