Does the keyboard slide down by default when a form is submitted using ng-submit?
I seem to be having the exact opposite problem of this guy here:
Reading his post it sounds like the keyboard is doing exactly what I want it to do - sliding down on submit.
But when using the ios emulator and I press enter the keyboard stays visible, and I have to use the “Done” button to dismiss it. Am I missing something obvious?
Thanks for the reply! Sorry, missed that somehow. It sounds exactly what I’m after, I just can’t seem to get it installed/working. I’m just extending the “Getting Started” app so downloaded the ionic-plugins-keyboard-master acrhive, unzipped to myApp/plugins, added
in the myApp/config.xml file, and placed a call to Keyboard.close() in my search function run from the ng-submit.
Sorry for the beginner questions, spent a few hours putting it in different folders, renaming things etc, but thought I better stop and ask for help before I screwed something up
Ah, don’t put the call to close the keyboard in the config.xml. That call should be in your controller, specifically in the function that you have for you ng-click function.
Haha, yeah that’s exactly where I put it - in the search() function which is in the controller
Sorry, my bad, my explanation probably wasn’t very clear.
Just to go through the steps…
I copied the complete downloaded ‘ionic-plugins-keyboard-master’ folder to myApp/plugins/
Add the following to myApp/config.xml
Finally inside my controller, I added a call to the ‘Keyboard.close()’ function to my own search function. In Chrome running simpleHTTP server, I get an error saying the Keyboard.close() function isn’t defined. In the ios simulator, I can’t see anything useful…
Sorry about all the questions, complete beginner here. So my plugin installation method is correct?
Here’s my controller…
.controller('FriendsCtrl', function($scope, Friends, Current) {
$scope.friends = Friends.all();
//Storing results in factory current so the results are displayed until user performs new search.
$scope.currentList = Current.all();
$scope.results = function(searchTerm){
Keyboard.close();
$scope.currentList.length = 0;
for(var i = 0; i <= $scope.friends.length-1 ; i++){
var compareThis = $scope.friends[i].name;
if (compareThis.indexOf(searchTerm) >=0){
$scope.currentList.push($scope.friends[i]);
}
}
}
})
@mhartington
In the ionic keyboard plugin documentation, it says cordova.plugins.Keyboard.close(); is only supported for IOs.
Is it possible to hide the keyboard on Android as well, because it remains open if a user submit a form without closing the keyboard (he scrolls down to find the submit button without closing the keyboard).
Just to let you guys know,
I have installed this plugin :
It works fine.
Usage
SoftKeyboard.show() to show the keyboard
SoftKeyboard.hide() to hide it
Keyboard visible callback: SoftKeyboard.isShowing(function(){ console.log('success'); }, function(){ console.log('fail'); })
BTW: To have callback for hiding and showing the keyboard you can use: "showkeyboard" / "hidekeyboard" events wich are not mentioned in the docs.
Would be awesome if it was implemented in the ionic keyboard plugin .