What I'm trying to do seems like a very common use case of Ember.Select, but I haven't found a solution yet.
I'm trying to set the default value of Ember.Select using a belongsTo Ember Data property. I have the following Ember.Select view in my template:
{{view Ember.Select content=neighborhoodOptions value=neighborhood.id optionValuePath="content.value" optionLabelPath="content.label"}}
The controller for this view looks like:
App.PropertyEditController = Ember.ObjectController.extend({
neighborhoodOptions: [{value: 1, label: 'Foo'}, {value: 2, label: 'Bar'}]
});
I am using Ember Data and have a model with a belongsTo property for this controller which looks like:
var attr = DS.attr;
App.Property = DS.Model.extend({
neighborhood: DS.belongsTo('neighborhood')
});
However, this does not set any default option when the page loads. What's worse, it makes the neighborhood.id undefined when I look the neighborhood model in the Ember Inspector console. If I remove the value attribute from the view, the neighborhood.id is defined again so it seems that the Ember.Select value property behavior is setting the id to undefined. I do not understand why it is doing this.
How can I bind the neighborhood id property and make it the default Ember.Select choice?