Reputation: 686
we are developing an application which is both mobile and desktop, when we use .focus()
on the mobile version the keyboard is not showing up, we try by triggering a click within the focus function $('#numeroCheque').focus(function(){
$('#numeroCheque').trigger('click');
});
but still no keyboard is shown, does anyone faced this issue before, and what can we do to solve it. Thanks.
Upvotes: 0
Views: 2953
Reputation: 56
make sure your keyboard element has native support for keyboard interaction and that the element can receive keyboard focus across different platforms. also make sure the tabindex attribute of .focus() is correct.
Upvotes: 1
Reputation: 1496
As I understand, you can't set the focus to an input element programmatically on mobile. There needs to be some kind of user interaction. If building out a Cordova application, you can disable this using the KeyboardDisplayRequiresUserAction
setting in your config file. But that is only if you wish to wrap your application in Cordova.
ref: https://cordova.apache.org/docs/en/2.7.0/guide/project-settings/ios/
The other option is to set the input
element attribute autofocus
but even this I believe won't work on mobile either.
Upvotes: 1
Reputation: 1275
Focusing is not enough, you need a click event to trigger focus, and wait until the page is fully loaded.
$(document).ready(function() {
$('#numeroCheque').click(function(e){
$(this).focus();
});
});
Upvotes: 0