简体   繁体   English

在流星js中的同一页上打开多个实现模型

[英]Open more than one materialize modal on same page in meteor js

id of 1st modal is "modal1" and 2nd modal id is "modal2"

HTML code -> HTML代码->

1st Modal Call on Same Page 同一页面上的第一个模态调用

<div class="input-field col s12 m6 left-align">
                <button class="btn waves-effect waves-light modal-trigger importButton" style="height:45px !important">Import Data
                    <i class="material-icons right">import_export</i>
                </button>
</div>

2nd Modal Call on Same Page 同一页面上的第二模式调用

<div class="modal-trigger" style="cursor: pointer;">
                <img src="abc.png" alt="" class="circle">
</div>

JS Code -> JS代码->

'click .modal-trigger': function(event) {
    event.preventDefault();
    $('#modal1').openModal();
},
'click .importButton':function(event) {
     event.preventDefault();
    $('#modal2').openModal();
}

您必须引用定义了modal2的另一个模板{{> import}}(我的模板名称为import)。

Your question is not very clear. 您的问题不是很清楚。 From what I understand, there are 2 modals that can be opened from the same template. 据我了解,可以从同一模板中打开2个模态。 The catch here is that bootstrap does not support multiple modals stacking up over each other. 这里要注意的是,引导程序不支持彼此叠加的多个模式

Multiple open modals not supported Be sure not to open a modal while another is still visible. 不支持多个打开模式,请确保在仍然可见另一个模式时不要打开一个模式。 Showing more than one modal at a time requires custom code. 一次显示多个模态需要自定义代码。

So, before the first modal is open, you must first always check if the other modal is in closed state, and similarly, before the second modal is open, you must check if the first modal is closed, if not then close it. 因此,在打开第一个模态之前,必须首先始终检查另一个模态是否处于关闭状态,类似地,在打开第二个模态之前,必须检查第一个模态是否处于关闭状态,如果没有关闭则将其关闭。

There is one package in meteor that appears to help handle multiple modals. 流星中有一个软件包似乎可以帮助处理多种模态。 you can check out peppelg:bootstrap-3-modal to get a better implementation of bootstrap modals in meteor. 您可以查看peppelg:bootstrap-3-modal以在流星中更好地实现bootstrap模态。 Specifically the part where they mention the use of below: 特别是他们提到以下用途的部分:

Modal.allowMultiple = true

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

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