问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/16246491/jquery-autocomplete-ipad-hide-keyboard-focus