I have got an Ember.Select in my template. The options are populated from content I get from a server. All the options are rendered fine. But when I want to show the selected value it will set the attribute to undefined.
Template:
{#with this as context}}
{{#each}}
<tr>
<td>{{name}}</td>
<td>{{view Ember.Select content=context.types optionValuePath='content.id' optionLabelPath='content.name' value=type}}</td>
</tr>
{{/each}}
{{/with}}
Controller:
types: function() {
return this.store.find('myType');
}.property()
Model I'm looping through:
DS.Model.extend({
name: DS.attr(),
type: DS.attr() // <= this is the selected type (id)
});
MyType model:
DS.Model.extend({
name: DS.attr()
});
This code will render all the options in the select element. Like so:
<select>
<option value="1">My first type</option>
<option value="2">My second type</option>
</select>
The following things I don't understand:
- When I inspect my data (ember inspect add-on) the property type is set to undefined.
- But when I select an option the type property is set with the right id.
- When I remove the
value=typethe type attributes have the correct value when I inspect the data.