Skip to content

Instantly share code, notes, and snippets.

@hergaiety
Created July 15, 2016 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hergaiety/fa34032eea085a544a3080c62f44d775 to your computer and use it in GitHub Desktop.
Save hergaiety/fa34032eea085a544a3080c62f44d775 to your computer and use it in GitHub Desktop.
Passing Actions Upward
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
foo: function(...args) {
console.log('Hit foo in bottom');
this.sendAction('foo', ...args);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
// I don't want to have to know what to pass up to the controller.
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Components are Crazy',
actions: {
foo: function(data) {
alert('It worked!', data);
}
}
});
<h1>Welcome to {{appName}}</h1>
{{the-top}}
<button {{action "foo" "bar"}}>Click Me!</button>
{
"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