Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery focus() method on the ipad [duplicate]

Tags:

jquery

focus

ipad

Possible Duplicate:
iPad HTML Focus

Does anyone know how to get the focus() method from jquery to work on the ipad, or perhaps a workaround? What I'm trying to do is to get the keyboard to pop up on a webpage since I have jquery capturing keystrokes to perform events. However, without a textbox on the page I don't know how to get the keyboard to pop up. Now that I have the textbox on the page, I'm trying to use jquery to set the focus to the textbox so the keyboard pops up. On top of this, I'm setting the textboxs style to display:none, so that the focus goes to the textbox but it's not seen, so the functionality appears to work. However, focus() is broken on the ipad! Can anyone help me?

like image 710
JesseBuesking Avatar asked Mar 13 '11 04:03

JesseBuesking


1 Answers

Unfortunately, the only way to get a keyboard to show, is during a user initiated event. This is something I've been fighting with myself as of late.

Below, ilumin has a good solution, but it's not the only one. Basically, from what I've found, as long as your are performing your .focus() function call inside of a user event (such as mouseup, or any of the touch events [which is probably preferred for a touch device]), then you shouldn't have a problem.

To an extent I understand why Apple made this limitation, but at the same time, it has made my work very challenging.

like image 112
NeoNexus DeMortis Avatar answered Sep 25 '22 11:09

NeoNexus DeMortis