frequent
frequent

Reputation: 28533

How to prevent the iPad keyboard going dead when submitting a form?

I'm having a strange issue:

I have a search from, which when I'm submitting on iPad will not hide the keyboard but stall it until the search results are being loaded.

So as soon as I hit enter on the keyboard, the iPad goes dead with open keyboard and only when the search is done, the keyboard hides and the results start apprearing.

Right now my script is listening to change events to trigger functions, such as the search form in question, which probably is the problem.

Question:
Is there a one-code-fits-all-devices approach to trigger a form submit, so my keyboard first disappears and then the search starts?

Thanks for inputs!

EDIT:
My button:

  <input type="text" value="" id="searchField" data-type="search" placeholder="Suche" class="ui-input-text ui-body-c">

My script handling it:

$('#searchField').keypress(function(e){
     if(e.which == 13){

        $('#searchField').trigger('blur');
        loadMulti( "yes" );
        return false;
        }
    });

Hm. I guess the whole thing.... isn't constructed very nice.

Upvotes: 1

Views: 569

Answers (2)

frequent
frequent

Reputation: 28533

Good ol setTimout saves the day:

window.setTimeout(function(){
     loadMulti( "yes" );
     },10);

It seems triggering an Ajax form submit really stalls the whole page, because I had my trigger for blur as well as my loading spinner activated from inside loadMulti, which fires my Ajax form submit. Neither one showed up, so I eventually thought why not set a timeout for everything to setup, the keyboard to hide and THEN fire the function.

Works... even with 5ms.

Upvotes: 1

Martin van Dam
Martin van Dam

Reputation: 106

As far as i know the ipad keyboard dissapears automatically on blur. There is no code posted but my guess is that your script blurs after the query is finished.

Upvotes: 1

Related Questions