iUI Dismiss Keyboard on GO

10 views
Skip to first unread message

David Ethell

unread,
Nov 23, 2007, 5:37:19 AM11/23/07
to iPhoneWebDev
This has been discussed in some other threads, but I have yet to see
an answer so I'm starting a new thread. Is there a way to dismiss the
keyboard when you are in a form field and click the GO button in the
keyboard? It seems that the focus stays inside the form input field
and so the keyboard stays up even after the page switches. The user
has to click "done" to close the keyboard. I notice this same problem
happens on the Movie Search sample from Joe's site so it looks like a
common problem.

Perhaps it is focus related? I tried setting focus to some other page
element without success so far, but I'm going to keep exploring that
avenue a bit.

If anyone knows a solution please post it.

Thanks!

David Ethell

wayne

unread,
Nov 25, 2007, 1:40:52 AM11/25/07
to iPhoneWebDev
> I tried setting focus to some other page element without success so far, ...

That does work, provided the other element is a non-keyboard input
component of the same form or div e.g. an invisible select element.
The
element will receive focus, then 300-500ms later it gets blur event
and the keyboard goes away. (It's a shame one has to do this kind
of silly stuff, when a plain simple keyboard element controllable
by the script, like a button or any other regular element, would put
an end to all the wasted time and bandwidth on this topic.)

David Ethell

unread,
Nov 27, 2007, 4:28:45 PM11/27/07
to iPhoneWebDev
Here's what I'm trying and it doesn't work yet. Inside the <form> tags
I have a SELECT tag with style of display:none. I gave it an id of
"dummyField". Then I modified iui.js so that the form.onsubmit
function has this at the top:

var dummyField = document.getElementById("dummyField");
dummyField.focus();

However, that does not see to give the SELECT box the focus and does
not drop the keyboard.

Any ideas?

David

David Ethell

unread,
Nov 29, 2007, 5:40:22 AM11/29/07
to iPhoneWebDev
Ok, finally got this to work by modifying the submitForm function so
that it gets my submit button element and focuses on it. I'm still not
happy with this implementation because it is not generic. Currently it
requires every form where I want the keyboard to close to have an
anchor button called "submitButton". Ideally I'd like to be able to
have my own javascript code that the iui submit looks for so that I'm
not hacking the iui files.

Here are the relevant changes in case it helps anyone (this is
certainly not the ideal way, but it works for now):

In my form I have a button named "submitButton":

<a class="whiteButton" id="submitButton" type="submit" href="#">Login</
a>

In iui.js I added this to the top of the submitForm(form) function:

var submitButton = document.getElementById("submitButton");
if ( submitButton != null ) {
submitButton.focus();
}

David
On Nov 27, 4:28 pm, David Ethell <deth...@gmail.com> wrote:
> Here's what I'm trying and it doesn't work yet. Inside the <form> tags
> I have a SELECT tag with style of display:none. I gave it an id of
> "dummyField". Then I modifiediui.js so that the form.onsubmit
Reply all
Reply to author
Forward
0 new messages