0
votes

Using Ember.Select, I am successfully rendering my dropdown menus

{{view Ember.Select
     content=businessType.acceptableValues
     optionLabelPath="content.name"
     optionValuePath="content.value"
     prompt=businessType.prompt
}}

The controller pulling the data from the model looks like:

businessType: function(){
        var content = this.get('content');
        return content.get(10);
    }.property('content')

I can't figure out how to set the selected value. I have tried setting the value to content.value, I have tried selectionBinding=content.value, but nothing is working for me. What am I not understanding for this.

Thanks

1

1 Answers

0
votes

Look at http://emberjs.com/api/classes/Ember.Select.html document.

It says:

The value attribute of the selected within an Ember.Select can be bound to a property on another object:

App.ApplicationController = Ember.Controller.extend({
  programmers: [
    {firstName: "Yehuda", id: 1},
    {firstName: "Tom",    id: 2}
  ],
  currentProgrammer: {
    id: 2
  }
});

{{view Ember.Select
       content=programmers
       optionValuePath="content.id"
       optionLabelPath="content.firstName"
       value=currentProgrammer.id}}

Interacting with the rendered element by selecting the first option ('Yehuda') will update the id of currentProgrammer to match the value property of the newly selected .

So you just have to bind some existing object property to Ember.Select value.