Search code examples
jqueryjquery-templates

jQuery templates each "value is not defined"


I am having an issue with jQuery templates. I have a simple template each loop:

{{each gameVersions}}
    <option value="${$value}" {{if max_game_ver == value}}selected="selected"{{/if}}>${$value}</option>
{{/each}}

The browser is throwing the following error: Uncaught ReferenceError: value is not defined. According to the jQuery documentation value should be accessible.


Solution

  • Replace value by its placeholder ${$value}. Try this.

    {{each gameVersions}}
        <option value="${$value}" {{if max_game_ver == "${$value}"}}selected="selected"{{/if}}>${$value}</option>
    {{/each}}