Skip to content

Loading…

iOS does not show keyboard on .focus() #3016

Closed
offsky opened this Issue · 5 comments

5 participants

@offsky

When I call .focus() on one of my text inputs or textareas, the iPhone keyboard does not automatically appear.

http://jsfiddle.net/kzUuG/1/

Tested on iPhone 4 running iOS5. This may be a jquery issue instead of jquerymobile, Im not sure. But, it would be nice if there was some workaround either way.

@ghost

As far as I know it isn't possible to show the iOS keyboard via javascript. You can focus an element, Safari will draw a blue "focused" border, but it won't raise the keyboard.

I'd be eager to learn a workaround if there's one.

@eddiemonge

iOS won't, as far as I can tell from testing, show the keyboard without some kind of user interaction.

Trying a setTimeout to load it doesnt work. But setting the focus on another element's onClick event brings it up.

http://jsbin.com/inunis/8

I believe this should be closed as an invalid bug.

@Wilto

Yeah, unfortunately, I’m third-ing this one: I’ve yet to find a way to trigger the iOS keyboard on focus.

@Wilto Wilto closed this
@chrisrowe

This now appears to be working under the button click. (iOS9 beta4)

@Orthocenter

following code works on my mobile Safari, Chrome and also desktop browser

// div is some selected element
                var f = function(event) {
                    $timeout(function() { // angular way, setTimeout is OK
                        input[0].focus();
                        event.preventDefault();
                    })
                };
                var mobile = false;
                div.on('click', function(event) {
                    if(mobile) return;
                    f(event);
                });

                div.on('touchstart', function(event) {
                    mobile = true;
                    f(event);
                });

                div.on('touchend', function(event) {
                    event.preventDefault();
                    event.stopPropagation();
                });
@slorber slorber referenced this issue in JedWatson/react-tappable
Closed

event argument is not provided to onTap consistently #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.