zitscher
zitscher

Reputation: 147

Can't use handlebars variable twice in each loop

I'm quite new to ember.js and handlebars and I'm trying to iterate through an array in my template.

<select name="district" id="select-district">
   {{#each districts}}
   <option value={{name}}> {{name}} ({{count}})</option>
   {{/each}}
</select>

Is there anything I am missing? Everything works fine when I remove the second variable name inside the loop. It seems like there is a problem in using a variable twice inside the loop.

The error: Uncaught TypeError: Cannot read property 'insertBefore' of null Any help would be greatly appreciated!

Upvotes: 1

Views: 842

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

I'd recommend using http://emberjs.com/api/classes/Ember.Select.html for your selector. Additionally for the future, when looping you shouldn't be using the context switching version of each, that's being deprecated. Instead use

{{#each d in districts}}
  {{d.name}} ...
{{/each}}

Upvotes: 1

Related Questions