Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Created January 31, 2017 22:01
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 samselikoff/ffd2d26270bd54a53080299bd0816913 to your computer and use it in GitHub Desktop.
Save samselikoff/ffd2d26270bd54a53080299bd0816913 to your computer and use it in GitHub Desktop.
Actions
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
value: 0,
actions: {
incrementValue(arg) {
this.incrementProperty('value');
console.log('the arg is', arg);
}
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
input {
display: block;
margin: 20px;
}
<p>The value is {{value}}</p>
<hr>
<label>Attribute context</label>
<input onkeyup={{action "incrementValue"}}>
<label>Handlebars value context</label>
{{input key-up="incrementValue"}}
{{input key-up=(action "incrementValue")}}
<label>Element space</label>
<input {{action "incrementValue" on="keyUp"}}>
{
"version": "0.11.0",
"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.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment