Saturday, 27 May 2017

IF conditional in EJS with Script tag doesn't work

I've some problem in here. I put script tag inside IF Conditional. Nah, script tag is running when condition is TRUE or FALSE.

For example

<% if (info) { %>
    <p><%=info%></p>
            <script type="text/javascript">
            alert("Hi")
            </script>
    <% } %>

Result :

IF = TRUE

alert("Hello world")

<p>Hello world</p>

IF = FALSE

alert("Hello world")

Paragraph attributes is rendering when IF conditional is TRUE. But script tag is running when IF Conditional is TRUE or FALSE, what i want the script tag running like HTML attributes.

Why this is happened? Thanks



via Ade Firman Fauzi

No comments:

Post a Comment