Skip to content

Instantly share code, notes, and snippets.

@ScottKelly
Forked from Bouke/ember-select.js
Created April 29, 2014 21:47
Show Gist options
  • Select an option

  • Save ScottKelly/3cc2652eae5bcf255760 to your computer and use it in GitHub Desktop.

Select an option

Save ScottKelly/3cc2652eae5bcf255760 to your computer and use it in GitHub Desktop.
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