如何在窗口准备就绪时打开物化模式? [英] How I can open a materialize modal when a window is ready?

查看:116
本文介绍了如何在窗口准备就绪时打开物化模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



<$ p $

我想打开一个模式窗口,当用户在窗口中时,我的意思是打开一个没有触发按钮的模式,我有这个例子。 p> < button data-target =modal1class =btn modal-triggerid =btn-1> Modal< / button>
< div id =modal1class =modal modal-fixed-footer>
< div class =modal-content>
< h4>模态标头< / h4>
< p>一堆文字< / p>
< / div>
< div class =modal-footer>
< a href =#! class =modal-action modal-close waves-effect waves-green btn-flat>同意< / a>
< / div>


如果我点击触发按钮,但它不起作用单击。
当窗口准备就绪时,我使用这段代码:

$ $ p $ $ $ $ $(function()
{
函数checkCode()
{
$(#btn-1)。click();
}
});

这会自动按下按钮并使模式自动打开的效果,但我不想

解决方案

我在materialize.js
中找到了解决方案我们必须使用:

  $(。MyModal)。openModal()

打开模态和:

  $(。MyModal)。closeModal()

关闭它。
实体化团队忘记刷新他们的文档。


I want to open a modal window when the user be in a window, I mean, open a modal without a trigger button, I have this example.

<button data-target="modal1" class="btn modal-trigger" id="btn-1">Modal</button>
<div id="modal1" class="modal modal-fixed-footer">
<div class="modal-content">
  <h4>Modal Header</h4>
  <p>A bunch of text</p>
</div>
<div class="modal-footer">
  <a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">Agree</a>
</div>

It works if I click on the trigger button, but I don't want a click. I use this code when the window is ready:

$(function()
{
    function checkCode()
    {
        $("#btn-1").click();
    }
});

This automatically push the button and make the effect that modal is auto opened, but I don't want to do this.

解决方案

I found the solution in materialize.js We must use:

$(".MyModal").openModal()

to open modals and:

$(".MyModal").closeModal()

to close it. Materialize team forgot refresh their documentation.

这篇关于如何在窗口准备就绪时打开物化模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆