Input error with keyboard on Galaxy S2 using jQuery Mobile and Phonegap

后端 未结 6 1653
天涯浪人
天涯浪人 2021-02-07 08:23

We are developing a mobile web app in jQuery Mobile 1.0.1 and Phonegap 1.4.1 and have run into issues with the keyboard on the galaxy s2.

We have a menu which slides out

6条回答
  •  说谎
    说谎 (楼主)
    2021-02-07 08:50

    I have/had the same issue on my Note II running 4.1.1 rooted using Phonegap 2.6.0 (though I can also replicate it in 2.5.0), jQuery Mobile 1.2.0, and jQuery 1.7.2. My keyboard is SwiftKey 4.0.1.128.

    Except rather than just one input causing me issues, my form has multiple inputs that eventually cause me trouble. It's a real headache because it's hard to replicate - the input always works at first, but if you switch between inputs randomly and long enough, it eventually stops working at a random time.

    This error used to happen fairly quickly, so that it would make it a pretty significant issue considering I would have to restart the app to get the form working again, which would eventually stop working yet again. My new form structure seems to work well; the error occurs after literally minutes of typing long strings and randomly switching inputs, which I assume no user will be doing; but it still upsets me that the error is there.

    I tried to get help on this error on the jQuery Mobile forum, but they gave me some snarky comment about how it's likely just my element ID usage, because apparently 99% (probably not even realistic) of JQM errors are from incorrect ID usage. I know for a fact my IDs are all unique across every page, but they insist it's an ID error without even trying to correctly diagnose the issue, but I digress.

    I should also note that I found the CSS solution that was provided in another answer in many other similar issues across the web, but not this exact issue; while I understand its usage, the CSS did not fix the issue for me.

    My form is dynamically loaded into a data-role="content" DIV inside of a data-role="page" DIV, so:

    I've found the best form structure, at least in my application, to cause the error least frequently is:




    The form HTML is fetched via AJAX and loaded into the DIV by:

    $(ajaxData).appendTo("#my-form-holder").trigger("create");
    

    Naturally, your form will be a bit different, and you may not even have a form since you just have a search input (getting to that in a moment). But if you do have a form, that's what works best for me.

    Since you're in Phonegap, you may not even need an action theoretically since you likely have jQuery to handle the input, but jQuery Mobile docs state forms must have action and method attributes, so I didn't want to go against that. Also, jQuery Mobile usually has a data-role="field-contain" DIV around each label/input group, but I found that the error occurred sooner if I did this. Again, the error occurs at an arbitrary moment that is never the same, so I don't know if it's directly related to the DIV.

    I also have an input hard-coded into another page:

    This seems to work fine. However, there are no other inputs to switch to, so the best I can do to try to replicate the error is focus/unfocus the input by tapping elsewhere on the page. Though, I am always able to type initially whereas your error doesn't let you type at all if I understand correctly. You may want to try that HTML structure and see if it works. There is no form tag surrounding that input.

    Our issues are a little different (I have most of my issues with a dynamically injected form whereas yours is hard-coded from what I gather), but this is the only page I could find anywhere that directly addresses this exact issue, so hopefully this helps and we can get some further insight on this issue.

提交回复
热议问题