Skip to content

Instantly share code, notes, and snippets.

@spencer516
Created November 17, 2015 01:22
Show Gist options
  • Save spencer516/e5a7bad81cbe705df9f3 to your computer and use it in GitHub Desktop.
Save spencer516/e5a7bad81cbe705df9f3 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
{{#my-parent as |disabled enable|}}
{{my-child is-disabled=disabled.A enable=enable id='A' opposite='B'}}
{{my-child is-disabled=disabled.B enable=enable id='B' opposite='A'}}
{{my-child is-disabled=disabled.C enable=enable id='C' opposite='D'}}
{{my-child is-disabled=disabled.D enable=enable id='D' opposite='C'}}
{{/my-parent}}
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
enable: function() {
this.getAttr('enable')(this.getAttr('id'), this.getAttr('opposite'));
}
}
});
{{#if is-disabled}}
{{id}} is disabled.
{{else}}
{{id}} is enabled.
{{/if}}
<button {{action 'enable'}}>Enable</button>
import Ember from 'ember';
export default Ember.Component.extend({
disabled: Ember.computed(function() {
return {};
}),
enableId(id, opposite) {
this.set('disabled.'+id, false);
this.set('disabled.'+opposite, true);
}
});
{{yield disabled (action enableId)}}
{
"version": "0.4.16",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment