Skip to content

Instantly share code, notes, and snippets.

@workmanw
Last active March 2, 2017 00:50
Show Gist options
  • Select an option

  • Save workmanw/4ac024cc987233de752759ea88418c38 to your computer and use it in GitHub Desktop.

Select an option

Save workmanw/4ac024cc987233de752759ea88418c38 to your computer and use it in GitHub Desktop.
{{input}} keyPress validation
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
inputValue: 50,
actions: {
keyPress(value) {
console.log(value);
let numValue = parseInt(value);
numValue = numValue > 100 ? 100 : numValue;
this.set('inputValue', numValue.toString());
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{input value=inputValue key-up="keyPress" on-change="onChange"}}
<br><br>
{{inputValue}}
{
"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