Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding keyboard hide button in accessory bar in Ionic

I am using the ionic framework to create my app and I use a lot of forms with modals. In order to move between fields a user normally taps on the space where there isn't any image however this can lead to unexpected behaviour.

I would like a button to hide the keyboard exactly like the image below.

iOS keyboard accessory bar

like image 395
Taylorsuk Avatar asked May 20 '15 13:05

Taylorsuk


1 Answers

If you are using cordova, you can first install this plugin

cordova plugin add com.ionic.keyboard

Then, in your callback, initiate

cordova.plugins.Keyboard.close();

Some information regarding attaching an element above the keyboard.

keyboard-attach is an attribute directive which will cause an element to float above the keyboard when the keyboard shows. Currently only supports the ion-footer-bar directive.

On iOS, if there is an input in your footer, you will need to set

cordova.plugins.Keyboard.disableScroll(true)

The Usage

<ion-footer-bar align-title="left" keyboard-attach class="bar-assertive">
    <h1 class="title">Title!</h1>
</ion-footer-bar>
like image 79
Eugene J. Lee Avatar answered Nov 13 '22 08:11

Eugene J. Lee