I have an Android Webview with a form with one textbox (#message). On tapping in it, soft keyboard comes up.
On typing "andro", it shows word suggestions: "andro | Android | android|" and so on. On selecting "android" from this and submitting the form, textbox gets empty, but the word suggestions show up as if "android" was filled in the textbox field i.e. it shows "android | Android | androids".
Setting element.val("") is not clearing off the word suggest. What event/statement will let Android Word Suggest know that the form has been submitted and to clear off the word suggestions?
The events on the form (#messageform) are below:
function newMessage(form) {
// process form here
...
form.find("#message").val("").focus();
};
$("#messageform").live("submit", function() {
newMessage($(this));
return false;
});
$("#messageform").live("keypress", function(e) {
if (e.keyCode == 13) {
newMessage($(this));
return false;
}
});
Form is like this:
<form action="/newmessage" method="post" id="messageform">
<textarea name="body" id="message" rows="1" width="100%"></textarea>
<开发者_如何学Pythoninput type="submit" class="send" value="Send"/>
</form>
Figured out that pressing enter on the soft keyboard cleared off the word suggestions. The problem was only on hitting submit button.
So, change submit button to normal button and added a enter key trigger on click.
$('#messageform').trigger(jQuery.Event('keypress', {keyCode: 13}));
精彩评论