zl程序教程

您现在的位置是:首页 >  其他

当前栏目

[AngularJS] Using an AngularJS directive to hide the keyboard on submit

On to The Using an angularjs directive submit
2023-09-14 08:59:19 时间

Pleasea refer to Link

<form ng-submit="foo()" handle-phone-submit>
  <input type="text" ng-model="query" name="query" />
  <button type="submit">OK</button>
</form

 

angular.module('Foobar', [])
.directive('handlePhoneSubmit', function () {
    return function (scope, element, attr) {
        var textFields = $(element).children('input[type=text]');
         
        $(element).submit(function() {
            console.log('form was submitted');
            textFields.blur();
        document.acvtiveElement.blur();  }); }; });