Skip to content

Instantly share code, notes, and snippets.

@scalvert
Last active August 18, 2016 19:15
Show Gist options
  • Save scalvert/21f9d8fd1bf7b008c205642abad7eae7 to your computer and use it in GitHub Desktop.
Save scalvert/21f9d8fd1bf7b008c205642abad7eae7 to your computer and use it in GitHub Desktop.
String actions with sendAction bubbling
import Ember from 'ember';
export default Ember.Component.extend({
click() {
this.sendAction('onTopLevel');
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
onTopLevel() {
console.log('I\m the mid level component, and I have to receive and resend the action up to the next component level.');
this.sendAction('onTopLevel');
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
onTopLevel() {
console.log('I have to be called via sendAction through all components in the hierarchy that exist between me and the call site.');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{top-level}}
<br>
<br>
{{yield}}
Mid Level
{{bottom-level onTopLevel="onTopLevel"}}
{{yield}}
Top Level
{{mid-level onTopLevel="onTopLevel"}}
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment