如何在if语句twig

时间:2018-04-23 07:47:32

标签: ajax symfony twig

我想从js脚本加载警报,该警报只应在满足条件时运行:

代码:

{% if user_perm.up_slug != "view_hospitals" %} 
<!-- <frame id="info" onload="errorLoad()"></frame> --> 
<!-- <div id="info" onload="errorLoad()"></div> --> 
<script type="text/javascript">
        errorLoad();
        function errorLoad()
        {
            $.confirm({
                icon: 'fa fa-question-circle-o',
                theme: 'supervan',
                closeIcon: true,
                animation: 'scale',
                type: 'orange',
                title: 'Sorry',
                content: "Your not permitted to view this page",
                buttons: {
                    "Go Home": function () {
                        window.location.replace('{{ base_url() }}/dashboard');
                    }
                }

            });
        }
    </script>
{% else %} ... {% endif %}

我知道onload在div上没有用,但我想要的是如果在if语句中满足条件,那么脚本会弹出一个警告。

我想要的是我希望函数errorLoad()在满足if条件时运行

0 个答案:

没有答案
相关问题