2

I use jquery ui autocomplete to search with an input.

When I click on the input on an ipad, the keyboard show up correctly.

Then I type some word and I have some search result that appears. sometimes, I can't see all the results on ipad. So I need to hide the keyboard. But when I hide the keyboard, the autocomplete menu that show the result disappear.

it's because I loose the focus on the input.

How can I stay focused or pointed on the current input with an touch device like an ipad?

I found this but I don't know how to implement it : http://forum.jquery.com/topic/autocomplete-menu-disappears-on-ipad

Sorry for my English, I'm French.

freaky
  • 990
  • 3
  • 17
  • 44

1 Answers1

3

Actually you just have to add the line:

if ((/iPhone|iPod|iPad/).test(navigator.userAgent) ) {return;}

to the beginning of the

.bind( "blur.autocomplete", function( event ) {

Function.

You can find this in the autocomplete.js (or similar name) in you jquery ui folder.

I'll give it another shot: go to jquery.ui.autocomplete.js and change this:

blur: function( event ) {
            if ( this.cancelBlur ) {
                delete this.cancelBlur;
                return;
            }

            clearTimeout( this.searching );
            this.close( event );
            this._change( event );
        }

to this:

blur: function( event ) {
if ((/iPhone|iPod|iPad/).test(navigator.userAgent) ) {return;}

            if ( this.cancelBlur ) {
                delete this.cancelBlur;
                return;
            }

            clearTimeout( this.searching );
            this.close( event );
            this._change( event );
        }

Can't test it here but i think this should fix it

s_qw23
  • 354
  • 2
  • 11
  • Thank you for the answer. But there isn't any blur.autocomplete in the js file... – freaky Apr 26 '13 at 23:17
  • Edited my post and added another approach. I hope this one will be more helpful. – s_qw23 Apr 27 '13 at 00:21
  • thank you for the answer. It works but it break click and select event on autocomplete menu. Now on touch device I can't select any result... – freaky Apr 27 '13 at 11:15
  • This does work, and can even be easily done to the min.js version as well. Tested on both iOS 6 and Android 4.2.2 – coop May 23 '13 at 14:36