I am trying to use the Ember.Select control to set an association id on a model. However, I can't seem to get the control to bind it's selection to an id attribute instead of the entire model object. Is this by design in the Ember.Select control? I have the following in my template:
{{view Ember.Select
contentBinding="App.peopleController.content"
selectionBinding="App.selectedPersonController.personId"
optionLabelPath="content.fullName"
optionValuePath="content.id"}}
Yet even with explicitly setting selectionBinding to the personId attribute it still seems to be binding to the person object. Full jsfiddle here: http://jsfiddle.net/PXVZb/10/
I would suggest to bind the selected person to your App.selectedPersonController
and create a property personId
which binds to the persons id
, see http://jsfiddle.net/PXVZb/11/
JS:
App.selectedPersonController = Ember.Object.create({
personIdBinding: 'person.id'
});
Handlebars:
{{view Ember.Select
contentBinding="App.peopleController.content"
selectionBinding="App.selectedPersonController.person"
optionLabelPath="content.fullName" }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With