keep keyboard open on Ionic when button click ( chat app )

偶尔善良 提交于 2020-02-03 10:55:55

问题


I have an Ionic v1 chat application, I made everything, but I encountred the famous problem when clicking on a send button (send chat) the keyboard loses focus from the input and then closes.

I've tried many approaches, but it none of them work:

  • Input directive to keep focus,
  • forcing focus on click event,
  • modifying the value of InputUserAction in config.xml to false.

Any help is much appreciated.

<div class="sender">
<input type="text" ng-model="..." class="...">
<div class="button-send">
<span class="send-chat"><i class="ion ion-send"></i></span>
</div>
</div>

回答1:


ALright found a fix! for all of you out there, who are using ionic for a chat like app, and want the keyboard to stay focused after clicking on a button,

Just, replace the button by a label with for="inputID" like so:

<div class="sender">
<input id="inputID" type="text" ng-model="..." class="...">
<div class="button-send">
<label for="inputID" class="send-chat"><i class="ion ion-send"></i></label>
</div>
</div>



回答2:


Try forcing the keyboard to open via it's cordova plugin https://github.com/ionic-team/ionic-plugin-keyboard#keyboardshow



来源:https://stackoverflow.com/questions/45858201/keep-keyboard-open-on-ionic-when-button-click-chat-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!