Skip to content

Instantly share code, notes, and snippets.

@lifeart
Last active March 11, 2021 10:14
Show Gist options
  • Save lifeart/760298eb5efd620e1710c8a789a3f915 to your computer and use it in GitHub Desktop.
Save lifeart/760298eb5efd620e1710c8a789a3f915 to your computer and use it in GitHub Desktop.
1
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { schedule } from '@ember/runloop';
export default class ApplicationController extends Controller {
queryParams = ['inputValue'];
@tracked _inputValue = '';
get inputValue() {
return this._inputValue;
}
set inputValue(v) {
console.log('setInputValue', v);
this._inputValue = v;
}
@action updateValue(event) {
this.inputValue = event.target.value + '1';
const input = document.querySelector('input');
console.log('beforeRender', input.value, input.getAttribute('value'));
input.value = 'Foo';
console.log('beforeRender - direct mutation', input.value, input.getAttribute('value'));
schedule('afterRender', function() {
console.log('aferRender', input.value, input.getAttribute('value'));
});
}
}
<input value={{this.inputValue}} {{on 'input' this.updateValue}}/>
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment