Autofocus on controller initialization


#1

Hello,
I try to focus on an input in a view when the controller is initialized (I want the keyboard to be opened too).
With the “autofocus” attribute on the input, it works just one time but the keyboard is not opened.
So how to focus on this input and open the keyboard every time my controller is initialized ? ^^
Thanks in advance for the help. :slight_smile:


#2

iOS? If iOS, you need this in your config.xml before you can programmatically set focus.

<preference name="KeyboardDisplayRequiresUserAction" value="false" />

#3

Unfortunatly my case is for Android at the moment. :stuck_out_tongue:


#4

Well HTML5 has an autofocus feature that you can apply to inputs. They will get focus on load.


#5

Yes, this is what I tried. (see my first message :slight_smile: )
I didn’t retry with the beta 4 yet, will do !


#6

do’ugh, thats what I get for only reading the title lol.