Skip to content

Instantly share code, notes, and snippets.

@onechiporenko
Last active September 15, 2016 21:04
Show Gist options
  • Save onechiporenko/d4396f999a030723c14dba1e5e430d19 to your computer and use it in GitHub Desktop.
Save onechiporenko/d4396f999a030723c14dba1e5e430d19 to your computer and use it in GitHub Desktop.
Action w/o quotes
import Ember from 'ember';
export default Ember.Component.extend({
actionA() {
console.log('component function handler');
},
actions: {
actionA() {
console.log('component action handler');
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
click() {
console.log('sub-component action handler');
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
emberVersion: Ember.VERSION,
appName: 'Actions w/o quotes',
actionA() {
console.log('controller function handler');
},
actions: {
actionA() {
console.log('controller action handler');
}
}
});
<h1>{{appName}}</h1>
Ember: <strong>{{emberVersion}}</strong>
<pre>\{{my-component}}</pre>
{{my-component}}
<p>Action with quotes and with <code>action</code>
<pre>\{{my-sub-component click=(action "actionA")}}</pre>
{{my-sub-component click=(action "actionA")}}</p>
<hr />
<p>Action with quotes and without <code>action</code>
<pre>\{{my-sub-component click="actionA"}}</pre>
{{my-sub-component click="actionA"}}</p>
<hr />
<p>Action without quotes and with <code>action</code>
<pre>\{{my-sub-component click=(action actionA)}}</pre>
{{my-sub-component click=(action actionA)}}</p>
<hr />
<p>Action without quotes and without <code>action</code>
<pre>\{{my-sub-component click=actionA}}</pre>
{{my-sub-component click=actionA}}</p>
<button {{action "click"}}>Press me</button>
{
"version": "0.10.5",
"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.8.0",
"ember-data": "2.8.0",
"ember-template-compiler": "2.8.0",
"ember-testing": "2.8.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment