Q:

Ember.Select two way binding for edit form

In my ember application I have defined a select element like this in my template:
{{view Ember.Select
    content=greetings
    optionValuePath="content.id"
    optionLabelPath="content.code"
    value=selectedGreeting
    selection=selectedGreeting
    prompt="Please choose"}}

The controller for this page (shared form and controller for create and edit form) looks like this:
greetings: [
    {code: "Mr.", id: 1},
    {code: "Mrs.", id: 2}
],
selectedGreeting: null,
actions: {
    save: function(){
        var person = this.get('model');
        if (person == null || person.id == undefined)
        {
            // create mode
            var greeting = this.selectedGreeting.id;
            // ....
            var newPerson = this.get('store').createRecord('person',{
                greeting: greeting,
                // ..
            });
            newPerson.save();
            this.transitionToRoute('index');
        }
        else
        {
            // edit mode
            person.set('greeting', this.selectedGreeting.id);
            person.save();
        }
    }
}

This works perfect when creating a new person, but when opening an existing one the select box shows the promt instead of the saved value (do I really have to do this with jQuery?).
Besides I suppose there must be an easier way to update the existing model with the selected values in the else branch, as the other properties get modified automagically.
Any suggestions would be appreciated, the documentation for Ember unfortunately does not help a lot in this case.

A:

The Ember.Select view has quite a few quirks. In fact, if I remember correctly, I saw an issue on Github to just have the whole thing rewritten. For now, I'm assuming that the prompt attribute takes precedence over the selection attribute. To get around that, I would just use a conditional in the template.
{{#if model}}
    {{view Ember.Select ... value=selectedGreeting}}
{{else}}
    {{view Ember.Select ... prompt='Please Choose'}}
{{/if}}

Also, your second question, if I understand you correctly, you should be able to just use selection=model.greeting to bind the selection value to the model property. And if you're using the template above, you can make it so it only applies to the former and not the latter.

