1

I have some javascript in a template that has some values set via the output of a query tag, I've stripped the template right back to contain just the following:

<script>

$(function() {
    $( "#weight-slider-range" ).slider({
        range: true,
        {exp:query sql="SELECT field_id_88 FROM exp_channel_data
                            INNER JOIN exp_store_stock using(entry_id) 
                                GROUP BY field_id_88 ORDER BY field_id_88 ASC"}
        {if count == 1} min: {count}, 
        {if:elseif count == total_results} max: {count}, 
        {/if}
        {/exp:query}
    });
});

</script>

But the 'if' conditional is being written to the html page, why isn't it being evaluated?

This is what's being written to the browser:

<script>

$(function() {
    $( "#weight-slider-range" ).slider({
        range: true,

        {if "1" == 1} min: 1, 
        {if:elseif "1" == "241"} max: 1, 
        {/if}

    });
});

</script>

It seems that EE is not parsing the 'if' statement as it believes it's a js command maybe?

5
  • 1
    Does this still happen even if this code is in a bare template? Nov 3 '14 at 12:32
  • no, it works in a separate template, what could be interferring with it?
    – wot
    Nov 3 '14 at 12:42
  • Lots of things. I'd start removing tags from the template bit-by-bit in order to isolate the problem. (My first guess would e that this is inside of a Channel Entries loop.) Nov 3 '14 at 13:49
  • I've stripped the template down to just what is didplayed above, it seems to be the javascript that's causing a problem, but this should be parsed after the query tags, so I don't understand how.
    – wot
    Nov 3 '14 at 13:59
  • Ah, it's inside a script tag - marking as duplicate as this conundrum has been answered previously. Nov 3 '14 at 19:06

Browse other questions tagged or ask your own question.