New Twiddle
import Ember from "ember";
export default Ember.Component.extend({
classNames: ["etch-field", "float-label__container"],
tagName: "label",
content: null,
inputClassName: null,
options: {
minimumResultsForSearch: -Infinity
},
placeholder: "",
tabIndex: 0,
actions: {
validate(oldValue, event) {
const value = event.srcElement.value;
const isValid = this.validate(value);
this.setProperties({
isValid,
value: isValid ? value : oldValue
});
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
init() {
console.log(this);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
value: 'foo',
queryParams: ["page"],
actions: {
validateA(oldValue, newValue) {
const valid = newValue === 'a';
if (valid) {
this.set('page', 2);
} else {
this.set('page', 1);
}
return valid;
}
},
model: ['a', 'b', 'c']
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#each model as |value|}}
{{input-dropdown placeholder="hello" value=value validate=(action "validateA" value)}}
{{/each}}
{{outlet}}
<br>
<br>
<div content=content
value=value
classNames=inputClassName
tabIndex=tabIndex
placeholder=placeholder
options=options>
<input
value={{value}}
oninput={{action "validate" (mut value)}} />
<pre>test: {{value}} {{isValid}}</pre>
</div>
<div class="float-label {{if isValid "float-label--visible"}}">
<span class="float-label__text">
{{#if isValid}}
{{value}}
{{else if required}}
{{i18n "required"}}
{{/if}}
</span>
</div>
{
"version": "0.8.1",
"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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}