E.g. a text field in AJAX forms, like a chat app or such. Typing text
the first time works fine, submitting works fine, but trying to type
after that doesn't seem to actually send the input to the field. The
keyboard buttons work though.
Example: http://enrogue.com/lace/
Select the bottom input box, type something, "Go", try to type somehing
else. Anyone (not) getting that bug?
-Kalle.
The workaround is to do this:
document.execCommand("selectAll");
document.execCommand("delete");
Instead of:
input.value = "";
Note, this workaround only works if your input already has focus. Also
note the focus() and blur() do nothing on the phone.
Hardy
Sent from my iPhone
Thank you very much for that fix! To make it work in "other browsers" as
well as the iPod, my complete fix looks as follows:
// Clear field value
try {
// iPhone whilst-focusing way
document.execCommand("selectAll");
document.execCommand("delete");
} catch (e) {}
// Other browsers' way + iPhone when not focused
this.textObj.blur();
this.textObj.value='';
this.textObj.focus();
Where this.textObj points to the text input field.
> Note, this workaround only works if your input already has focus. Also
> note the focus() and blur() do nothing on the phone.
With the way above, it clears the input box in all cases, in all
browsers (well, I didn't test IE cause I'm in linux, but it works in
Firefox, Safari 3, and on the iPhone).
Thanks again. :)
-Kalle.
You should consider posting some html that demonstrates the bug, and
send the workaround, to Apple's RADAR bug reporter.
-- Christopher Alln
Steps to Reproduce:
- Create a web page with a form and a text input element.
- Set the onsubmit handler to reset the input field's contents (to '').
- Load the page on an iPhone.
- Type something into the field and "send".
- Try typing something else after the text you previously typed has been
cleared.
Expected Results:
The keyboard is expected to continue being able to provide text to the
input field.
Actual Results:
The keyboard does not function as expected.
Regression:
The following workaround fixes this bug;
Replace:
input.value=''
With:
document.execCommand("selectAll");
document.execCommand("delete");
The following workaround fixes this bug and remains compatible with
other major browsers:
// Clear field value
try {
// iPhone whilst-focusing way
document.execCommand("selectAll");
document.execCommand("delete");
} catch (e) {}
// Other browsers' way + iPhone when not focused
this.textObj.blur();
this.textObj.value='';
this.textObj.focus();
Where this.textObj points to the text input field.
Notes:
The problem can be observed here: http://enrogue.com/lace-broken/
The solved version of the above problem can be observed here:
http://enrogue.com/lace/
-----------------------------------
-Kalle.