Luke
Luke

Reputation: 39

Phonegap keyboard scrolls the page up and down on focused input

When using a jQuery Mobile dialog with an focused input field, the page continuously scrolls up and down because of the keyboard that appears. This is on a rather small phone (HTC Explorer), but the problem does not exist in larger phones such as a HTC Sensation.

When removing the keyboard from the screen, the problem disappears.

Does anyone know any way to fix this?

Thanks in advance

Upvotes: 1

Views: 5592

Answers (2)

Ismail Ali
Ismail Ali

Reputation: 111

You can simply switch your activity's windowSoftInputMode flag to "adjustPan". Check the official documentation for more info.

Upvotes: 1

Devgeeks
Devgeeks

Reputation: 5647

I got around this basically by immediately scrolling the page back to the top:

$('#myInput').bind('focus',function(event){
    window.scrollTo(0, 0);
    document.body.scrollTop = 0;
});

Upvotes: 2

Related Questions