Skip to content

Instantly share code, notes, and snippets.

@Bouke
Created April 11, 2013 14:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Bouke/5363838 to your computer and use it in GitHub Desktop.
Save Bouke/5363838 to your computer and use it in GitHub Desktop.
Ember.Select allowing options to be disabled. Usage `{{view Ember.Select ... optionDisabledPath="content.disabled"}}`
var get = Ember.get, getPath = Ember.getPath, set = Ember.set, fmt = Ember.String.fmt;
Ember.Select.reopen({
optionDisabledPath: null
});
Ember.SelectOption.reopen({
attributeBindings: ['disabled'],
init: function() {
this.disabledPathDidChange();
this._super();
},
disabledPathDidChange: Ember.observer(function() {
var valuePath = get(this, 'parentView.optionDisabledPath');
if (!valuePath) { return; }
Ember.defineProperty(this, 'disabled', Ember.computed(function() {
return get(this, valuePath);
}).property(valuePath));
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment