Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is there a way to focus core-input or paper-input element?

What I want to achieve is: set cursor to input element so user can start typing.

This way he will not be forced to click on element before writing.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
211 views
Welcome To Ask or Share your Answers For Others

1 Answer

core-input has now a .focus() method it's delegating to the internal 's focus()

From the core-input.html code:

focus: function() {
    this.$.input.focus();
  }

What means that in your own code you need to call it like following:

elem[0].focus()

In my own case, I am calling focus from a timeout. In this case a bind is necessary for core-input to make a right use of this:

$timeout(elem[0].focus.bind(elem[0]));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...