Last active
January 12, 2018 19:51
-
-
Save peterjmag/17ae149396bc249c027f9ca274a1f7ae to your computer and use it in GitHub Desktop.
Declaratively selecting an option from a list
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({ | |
actions: { | |
onSelect(sizeValue) { | |
this.get('onSelectSize')(sizeValue); | |
} | |
} | |
}); |
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.Controller.extend({ | |
appName: 'Ember Twiddle', | |
selectedSize: '1gb', | |
sizeOptions: [ | |
{ | |
value: '1gb', | |
label: '1 GB' | |
}, | |
{ | |
value: '2gb', | |
label: '2 GB' | |
}, | |
{ | |
value: '4gb', | |
label: '4 GB' | |
}, | |
{ | |
value: '8gb', | |
label: '8 GB' | |
}, | |
{ | |
value: '16gb', | |
label: '16 GB' | |
}, | |
], | |
actions: { | |
onSelectSize(sizeValue) { | |
this.set('selectedSize', sizeValue); | |
} | |
} | |
}); |
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
// Stolen from https://emberigniter.com/how-to-equals-conditional-comparison-handlebars/ | |
// to avoid the ember-truth-helpers dependency | |
import Ember from 'ember'; | |
const eq = (params) => params[0] === params[1]; | |
export default Ember.Helper.helper(eq); |
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
body { | |
margin: 12px 16px; | |
font-family: sans-serif; | |
} | |
.size-chooser-list-item { | |
cursor: pointer; | |
} |
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.13.0", | |
"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.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment