This question is a follow-up to this one: polymer focus() on <paper-input> or <core-input> element
How can I focus in a paper-input
element using the Javascript API ?
(using Polymer 1.0)
This question is a follow-up to this one: polymer focus() on <paper-input> or <core-input> element
How can I focus in a paper-input
element using the Javascript API ?
(using Polymer 1.0)
If you have an element:
<paper-input id="my-input" label="What's on your mind?"></paper-input>
paper-input is a wrapper for business logic and stylish of a more deep-down input
element which you can reach through:
document.getElementById('my-input').$.input
To focus, just write:
document.getElementById('my-input').$.input.focus();
document.getElementById('my-input')
I used a <paper-input>
not inside a Polymer Element template, that is why –
Impend <paper-input autofocus></paper-input>
will automatically focus immediately, or if you'd prefer to control the timing yourself in Javascript you can use paperInput.$.input.focus()
.
© 2022 - 2024 — McMap. All rights reserved.
this.$.my-input.$.input.focus()
. Also, if you happen to do this the same time as thepaper-input
is being shown, you should callfocus()
inside asetTimeout(function(){...}, 0}
call. – Domitiladomonic