Hello guys I have model Currency. I have fields name:string, default:boolean. In my db only one record can have default value and i want this record was selected in select tag.
Example:
name: Eur default:false
name: USD default: true
name: RUR default: false
I want to have :
<selected>
<option>Eur</option
<option selected=selected>USD</option
<option>RUR</option
</selected>
Route.js
EmberMoney.IncomesRoute = Ember.Route.extend
model: ->
EmberMoney.Income.find()
setupController: (controller) ->
controller.set('currencies', EmberMoney.Currency.find());
incomes.handlebars
// Some output with Incomes records
{{view Ember.Select
contentBinding="controller.currencies"
optionLabelPath="content.name"
optionValuePath="content.id"}}
You can subclass
Ember.Selectand overrideselectionas such:Because
selectionin your subclass doesn't have avalueparameter, the computed property will get permanently replaced for that instance as soon as the selection is changed.Note that if you set up a binding for
selection,selectionwill be overridden almost immediately, and you'll instead have to define this property on the source object or get more complicated: