BorisMoore/jquery-tmpl

Data and option in the same {{if}}

Closed this issue · 6 comments

When i try to use simple data and $item values in {{if }} conditions, just dont recognize the data value anymore.

Here is a sample:
http://jsfiddle.net/aYSBX/

<select id="test"></select>    
<script id="template-test" type="text/x-jquery-tmpl">
    <option value="${cod}" {{if  $item.selected != cod}}disabled{{/if}}>${name}</option>
</script>

Works for me and gives

<select id="test"><option value="1" disabled="">test 1</option><option value="2">test 2</option><option value="3" disabled="">test 3</option></select>

Give "disabled is not defined". And tks

But disabled is not defined on items 2 and 3. This works without throwing: if $data.disabled... Or define disabled:false on the other data items.

Excelent! Thank you!