Skip to content

Instantly share code, notes, and snippets.

@devinus
Last active September 11, 2015 18:07
Show Gist options
  • Save devinus/b663e28c60942f4c3d25 to your computer and use it in GitHub Desktop.
Save devinus/b663e28c60942f4c3d25 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
function optionsProperty(dependentKey) {
return Ember.computed(dependentKey, function() {
return this.get(dependentKey).split(',').map(Function.prototype.call, String.prototype.trim);
});
}
export default Ember.Controller.extend({
options: 'Red, Green, Blue',
values: optionsProperty('options'),
valuesChanged: false,
valuesDidChange: Ember.observer('values.[]', function() {
console.log('valuesDidChange', this.get('allValues'));
this.set('valuesChanged', true);
})
});
{{input value=options}}<br>
<br>
allValues Changed: {{valuesChanged}}
{
"version": "0.4.10",
"dependencies": {
"lodash": "https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.js",
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment