Skip to content

Instantly share code, notes, and snippets.

@stefanpenner
Forked from devinus/application.controller.js
Created September 11, 2015 18:07
Show Gist options
  • Save stefanpenner/a3109c04e37211cd8dc8 to your computer and use it in GitHub Desktop.
Save stefanpenner/a3109c04e37211cd8dc8 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({
init() {
this._super(...arguments);
this.get('values'); // initialize values CP
},
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>
ASDallValues 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