Skip to content

Instantly share code, notes, and snippets.

@Emerson
Forked from rwjblue/components.one-way-input.js
Created January 28, 2016 19:39
Show Gist options
  • Save Emerson/fa925580c06f6327e350 to your computer and use it in GitHub Desktop.
Save Emerson/fa925580c06f6327e350 to your computer and use it in GitHub Desktop.
One Way Input
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'input',
type: 'text',
attributeBindings: ['value'],
input(e) {
let val = this.readDOMAttr('value');
/*
* this.attrs.update(val)
*
* OR...
*
* this.attrs.value.update(val)
*/
this.attrs.value.update(val);
}
});
<h1>Welcome!</h1>
{{currentValue}}
<br>
{{one-way-input
value=currentValue
update=(action (mut currentValue))
}}
{{outlet}}
{
"version": "0.4.8",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.2.0",
"ember-template-compiler": "2.2.0",
"ember-data": "2.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment