Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ember.Select allowing options to be disabled. Usage `{{view Ember.Select ... optionDisabledPath="content.disabled"}}` (Update to match `optionValuePath` and `optionLabelPath` implementation in Ember.js)
var get = Ember.get, set = Ember.set, computed = Ember.computed, defineProperty = Ember.defineProperty, observer = Ember.observer;
Ember.Select.reopen({
optionDisabledPath: null
});
Ember.SelectOption.reopen({
attributeBindings: ['disabled'],
init: function() {
this.disabledPathDidChange();
this._super();
},
disabledPathDidChange: observer('parentView.optionDisabledPath', function() {
var disabledPath = get(this, 'parentView.optionDisabledPath');
if (!disabledPath) { return; }
defineProperty(this, 'disabled', computed(function() {
return get(this, disabledPath);
}).property(disabledPath));
})
});
@lxcodes

This comment has been minimized.

Copy link

lxcodes commented Nov 13, 2014

@SaladFork, this should work if the value at optionDisabledPath changes correct? Example looks great, but trying to apply it to something I have isn't working.

@lxcodes

This comment has been minimized.

Copy link

lxcodes commented Nov 13, 2014

@SaladFork, disregard. Just wasn't loading the module facepalm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.