Skip to content

Instantly share code, notes, and snippets.

@blatyo
Created July 15, 2016 13:10
Show Gist options
  • Save blatyo/8b10f4ff04364903167c12a863cd1d51 to your computer and use it in GitHub Desktop.
Save blatyo/8b10f4ff04364903167c12a863cd1d51 to your computer and use it in GitHub Desktop.
Child calls Parent
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
callParent() {
this.sendAction('callParent', this.get('name'));
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
callParent(childName) {
this.set(childName);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{#the-parent as |callParent|}}
{{the-child callParent=callParent name="bob"}}
{{the-child callParent=callParent name="jim"}}
{{/the-parent}}
<br>
<br>
<button onClick={{action "callParent"}}>Send to Parent {{name}}</button>
{{yield (action 'callParent')}}
{{#if childName}}
{{childName}} called me
{{/if}}
{
"version": "0.10.1",
"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.1",
"ember-template-compiler": "2.6.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment