Angu Angu - 4 months ago 56
Android Question

ionic keyboard focus on input box issue

I am using angular with ionic

I have used below code

<input type="number" name="foo" ng-model="field.field_value" class="form-number" ng-focus="keyboardFocus(this)" >

$scope.keyboardFocus=function(t){
var a= $(t).attr('class');
alert(a);
// $ionicScrollDelegate.scrollBottom();
// $ionicScrollDelegate.$getByHandle(t).scrollTop();
$("."+a).css('position','absolute');
$("."+a).css('top','0px');
}


But scroll is not working in current position on textbox. keyboard focus on textbox is not working but type any text foucus is working

Answer

Imho, no need to use $ionicScrollDelegate, change position, scroll manually or any other complicated stuff.

You just need the Ionic Keyboard Cordova plugin to be installed. See the explanation here.

To install it: cordova plugin add com.ionic.keyboard

Nothing else to do. On focus, the page will move automatically.

Of course, it will work only on real devices, but in my experience, with this plugin, focused form elements are never hidden under the keyboard.

Comments