Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent cordova to hide the keyboard when the input loses the focus

Tags:

cordova

I'm making a chat application for android with phonegap but i'm facing a problem.

I have a text area field (where the users can write their messages) and a button to send the messages.

When the user clicks on the text area, the keyboard comes up. However, when the user clicks the button to send the message, the text area field loses the focus and the keyboard disappears. I'd like to keep to keyboard displayed and give back the focus to the text area.

I've tried to select the keyboard with

$('#text-area).focus()

But it didn't work out.

I have also added this line to my config.xml.

<preference name="KeyboardDisplayRequiresUserAction" value="false"/>

I've tried to use the plugin https://github.com/driftyco/ionic-plugins-keyboard. When the keyboard is going to hide, it fires an event but the only thing I can do is to open it again with

cordova.plugins.Keyboard.show();

The problem is that the keyboard hide/show and the animation is still triggered.

Any advices ?

like image 518
David Defrenne Avatar asked Jan 15 '15 17:01

David Defrenne


1 Answers

I had the similar issue. You need to use focus directive for that just use this link i think you get the point and some help :

Set element focus in angular way

like image 132
Parvindra Singh Avatar answered Oct 19 '22 12:10

Parvindra Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!