物化引导程序未被触发

时间:2016-06-03 08:35:06

标签: javascript jquery css materialize

我有这样的代码,当用户成功添加新用户时,它将触发模态。我使用了materialize并且没有触发模态。这是我的代码的一部分:

<div id="thisismymodal" class="modal">
    <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>
</div>

@if( Session::has('uadded') )
{{ Session::forget('uadded') }}
<script>    
    alert("well hello there!");
    $(document).ready(function()
    {
        $('#thisismymodal').leanModal();
        $('#thisismymodal').openModal();
    });
</script>

@endif

仅触发警报而不是模态。关于我的代码出错的任何想法?

1 个答案:

答案 0 :(得分:0)

要通过某种方式打开模态,您不需要 $(&#39; #hisismymodal&#39;)。leanmodal(),因为这仅用于触发按钮点击。正如我所看到的,你的模态应该以编程方式启动,因此只需要 $(&#39; #hisismymodal&#39;)。openModal();

我假设你使用php将用户添加到数据库中。你有&#39; if&#39;检查数据是否已成功写入数据库的条件?

如果&#39;您可以在其中启动您的脚本。语句是否成功写入数据。

相关问题