emberjs/data — Issue #82: selectionBinding in Ember.Select don't work together with associations
Author: sandstrom
Created: 2012-02-06 15:20:08+00:00
State: open

There seem to be a problem with associations and Ember.Select (built-in view). My guess is that the objects are compared with === and the comparison returns false, since they are different instances. I've tried to track down the lines in the source where this happens, but haven't found it.

Handlebars code:

This is the javascript:

window.EmberApp = Em.Application.create()

EmberApp.store = DS.Store.create({
adapter: DS.fixtureAdapter
})

EmberApp.Country = DS.Model.extend({
name: DS.attr('string')
})

EmberApp.Country.FIXTURES = [{ id:"us", name: "US"}, { id:"se", name:"Sweden"}];

EmberApp.AllCountries = Ember.ArrayProxy.create({content:EmberApp.Country.FIXTURES});

EmberApp.User = DS.Model.extend({
country: DS.hasOne(EmberApp.Country, { key: "countryId" })
})

EmberApp.MyView = Em.View.extend({

user: EmberApp.store.createRecord(EmberApp.User, {
name: "Kalle",
countryId: "se"
})

testId: "se" #

})

console.log( EmberApp.store.find(EmberApp.Country, 'se') )

http://jsfiddle.net/sandstrom/YJ7zM/3/