Skip to content

Instantly share code, notes, and snippets.

@andrewhavens
Created April 26, 2016 22:15
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 andrewhavens/8db1f47fffae0072a79bfed1244ddc01 to your computer and use it in GitHub Desktop.
Save andrewhavens/8db1f47fffae0072a79bfed1244ddc01 to your computer and use it in GitHub Desktop.
callback chain
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
itemSelected(item) {
console.log("itemSelected", item);
this.get("itemCallback")(item);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
itemSelected(item) {
console.log("list", item);
this.get("listCallback")(item);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
topMostCallback(item) {
console.log("topMostCallback", item);
}
}
});
<p>Below, is a component with a child component</p>
{{the-list listCallback=(action "topMostCallback")}}
<span {{action "itemSelected" "fooItem"}}>
List Item (click me)
</span>
<ul>
{{list-item itemCallback=(action "itemSelected" "fooItem")}}
</ul>
{
"version": "0.7.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": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.4/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment