Skip to content

Instantly share code, notes, and snippets.

@zackthehuman
Created June 16, 2016 18:10
Show Gist options
  • Save zackthehuman/4e9d86edc1e27c2c1835bd560614a299 to your computer and use it in GitHub Desktop.
Save zackthehuman/4e9d86edc1e27c2c1835bd560614a299 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
selectionChanged(value) {
// Returns a function (it should!)
let action = this.get('attrs.onSelectionChanged');
if(action) {
action(value);
}
}
},
items: [
{ value: 123, label: "One Two Three" },
{ value: 456, label: "Four Five Six" },
{ value: 789, label: "Seven Eight Nine" }
]
});
import Ember from 'ember';
export default Ember.Component.extend({
buttonText: "Nothing!"
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{my-parent}}
<br>
<br>
<select onchange={{action "selectionChanged" value="target.value"}}>
{{#each items as |item|}}
<option value={{item.value}}>{{item.label}}</option>
{{/each}}
</select>
<p>{{buttonText}}</p>
{{my-child onSelectionChanged=(action (mut buttonText))}}
{
"version": "0.9.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.6.0",
"ember-data": "2.6.0",
"ember-template-compiler": "2.6.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment