Javascript Question

How I can open a materialize modal when a window is ready?

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 class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat ">Agree</a>

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 checkCode()

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

Answer Source

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


to open modals and:


to close it. Materialize team forgot refresh their documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download