Forked from tomlagier/components.child-component.js
Last active
April 15, 2016 20:11
-
-
Save alexspeller/fc8c8489559eccad7f9e3dca26a0a7a0 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
click() { | |
this.attrs.toggleHeight(); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
heights: Ember.Object.create(), | |
actions: { | |
toggleHeight(item) { | |
this.heights.toggleProperty(item.item); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const Wrapper = Em.Object.extend({ | |
checked: Ember.computed.alias('state.checked') | |
}); | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
items: Ember.A(['red', 'blue', 'green']), | |
states: {}, | |
decoratedItems: Ember.computed.map('items', function(item) { | |
let state = this.states[item]; | |
state || (state = this.states[item] = Ember.Object.create()); | |
return Wrapper.create({ item, state }); | |
}), | |
actions: { | |
addItem() { | |
this.get('items').addObject('yellow'); | |
}, | |
removeItem() { | |
this.get('items').removeObject('yellow'); | |
}, | |
toggleChecked(item) { | |
this.get('decoratedItems').findBy('item', item).toggleProperty('checked'); | |
}, | |
changeItem() { | |
this.get('items').replace(0, 1, 'orange') | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.7.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.4.4", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js", | |
"ember-template-compiler": "2.4.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment