Polymer receiving paper input, core input field value when a key is pressed

I have a paper input element

<paper-input id="{{ id }}" label="{{ label }}" on-keyup="{{ keypressHandler }}" value="{{ value }}"> </paper-input> 

and I can catch the event when the key is released.

 Polymer("app-input", { ready: function() { this.value = false; }, keypressHandler: function(event, detail, sender) { console.log("inputChanged"); console.log(this.value); } }); 

But this.value changes only when the focus is removed from the input field, so I can’t get the value of the elements when the button is released.

How can I get the value of elements in keypressHandler ()?

+6
source share
1 answer

For paper-input (and core-input ), inputValue is a real-time value , and value is a fixed value (updated when the user blurs a field or gets into it).

Also, consider using data observation instead of events.

 <paper-input id="{{ id }}" label="{{ label }}" inputValue="{{ value }}"> </paper-input> ... Polymer("app-input", { valueChanged: function() { console.log("valueChanged"); console.log(this.value); } }); 
+9
source

Source: https://habr.com/ru/post/971492/


All Articles