Forked from alexspeller/components.child-component.js
Created
April 15, 2016 20:11
-
-
Save tomlagier/1c812efe97ea8a839e68234004215877 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains 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 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 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 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 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