Running textbox.blur after pressing enter with angularjs

I have a small angularjs app that I developed for iPad (Safari browser). At the top is a text box that is used as a filter for ng-repeat. What I'm trying to achieve is to close the keyboard on the ipad as soon as someone presses the "GO" button. I saw how to close the keyboard to blur the input element Hide iPad keyboard by pressing the back key

I use the AngularUI library, so I fire the onKeyUp event and detect the input key.

This is the html for the text box. I am using the ui-keypress event to call keypressCallback

<input ng-model="query" type="text" id="query" placeholder="product name or number" class="big radius" autocomplete="off" ui-keypress="{13:'keypressCallback($event)'}">

Below is a shortened version of javascript that only contains the keypressCallback function

var GunnersenApp = angular.module( "GunnersenApp", ['ui'] );

GunnersenApp.controller(
'SwatchListCtrl',
function ($scope, $http) {      

    $scope.keypressCallback = function($event) {
        alert('enter');
        $event.preventDefault();
    };      

}
);

, , .

, , URL: http://thejonesmobile.com/gunnersen/

+5
2

input.blur()? :

$scope.keypressCallback = function($event) {
    $event.target.blur();
};

.

+11

:

document.formName.fieldName.blur();
0

All Articles