The correct if statement should look like that:
{{if item1 == item2}}selected{{/if}}
- without dollar sign
Pregunta
I am using Knockout and JQuery.tmpl libraries. My template works incorrect. Here it is:
<script type="text/html" id="filters">
{{each(i1, item1) addedFilters}}
<div>
<select>
{{each(i2, item2) filters}}
<option value='${SystemFieldName}'
{{if $item1 == $item2}}selected{{/if}}>
${Field}</option>
{{/each}}
</select>
<input type="text" data-bind="value: Value" />
</div>
{{/each}}
</script>
The problem is in IF statement. It says: Uncaught ReferenceError: $item1 is not defined.
Why?
(Without if statement it works as it should be)
Solución
The correct if statement should look like that:
{{if item1 == item2}}selected{{/if}}
- without dollar sign