iPad HTML Focus
I have an issue with focusing a text field on the iPad. Where I use:
$(document).bind("click",function(event) {
alert('click');
focusTextArea();
});
The focus is set to the text area, and a keyboard appears. However when called with touchend, focusTextArea
is not called and the keyboard is not made visible. My focusTextArea
function is:
function focusTextArea() {
$('#textArea').focus();
}
Does anybody know why this occurs, and how I might be able to get this to work?
TIA,
Adam
Unfortunately, focusing is not possible with the iPad. The only way the focus will be placed in the desired field is when the user 'clicks' on the desired field.
Update 2015-01-08:
As explained in this answer by Matt:
... iOS will only allow focus to be triggered on other elements, from within a function, if the first function in the call stack was triggered by a non-programmatic event. In your case, the call to setTimeout starts a new call stack, and the security mechanism kicks in to prevent you from setting focus on the input.