Android jQuery () workaround

I am working on an HTML5 mobile application (using regular jQuery, not mobile) that implements its own autocomplete list that appears under the text box. The user selects an option from the list, the word is autocomplete, and the user continues to type as usual.

The problem is that the user goes beyond the text field to select an item from autocomplete, so the text field instantly loses focus. Since focus () is disabled in the Android browser, I cannot immediately refocus and save the last caret position, as usual.

Is there a workaround that will allow me to reorient myself to the text field while maintaining the caret position, since there will be regular calls to blur () and focus ()?

Edit: Sources of the basic assumption: here it is mentioned https://stackoverflow.com/a/220942/ ... and here: http://ambrusmartin.wordpress.com/2012/08/30/soft-keyboards-in-android-iphone-phonegap- applications-when-we-call-focus / (already tested solution is mentioned in the link)

+3
source share
1 answer

Instead of re-focusing the text field, I would recommend not losing focus in the first place. I achieve this by preventing the default action on mousedown .

Here is jQuery, assuming list is your parameter list, and all parameters have a listEl class:

 list.on('mousedown', '.listEl', function(e) { e.preventDefault(); }); 
+1
source

All Articles