Skip to content

Instantly share code, notes, and snippets.

@cloke
Created March 19, 2012 18:15
Show Gist options
  • Select an option

  • Save cloke/2122469 to your computer and use it in GitHub Desktop.

Select an option

Save cloke/2122469 to your computer and use it in GitHub Desktop.
M.Select = Em.Select.extend({
value: Ember.computed(function(key, value){
var content = this.get('content'),
selection = this.get('selection'),
self = this,
optionValuePath = this.get('optionValuePath');
if ( selection ) {
this.setPath('bindingContext.type', selection.type)
}
if (value != undefined){
content.forEach(function(item, idx){
if (item.id && item.id == value)
{
self.set('selection', item);
return;
}
});
return value;
}
return this.get('selection')?
this.get('selection').id :
null;
}).property('selection').cacheable()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment