diff --git a/app/directives/autofocus.js b/app/directives/autofocus.js index 0b9029c33..7843e8139 100644 --- a/app/directives/autofocus.js +++ b/app/directives/autofocus.js @@ -1,11 +1,10 @@ -angular -.module('portainer') +angular.module('portainer') .directive('autoFocus', ['$timeout', function porAutoFocus($timeout) { var directive = { restrict: 'A', - link: function($scope, $element) { + link: function(scope, element) { $timeout(function() { - $element[0].focus(); + element[0].focus(); }); } }; diff --git a/app/directives/onEnterKey.js b/app/directives/onEnterKey.js new file mode 100644 index 000000000..1d13e8d22 --- /dev/null +++ b/app/directives/onEnterKey.js @@ -0,0 +1,18 @@ +angular.module('portainer') +.directive('onEnterKey', [function porOnEnterKey() { + var directive = { + restrict: 'A', + link: function(scope, element, attrs) { + element.bind('keydown keypress', function (e) { + if ( e.which === 13 ) { + e.preventDefault(); + scope.$apply(function () { + scope.$eval(attrs.onEnterKey); + }); + } + }); + } + }; + + return directive; +}]); diff --git a/app/directives/ui/datatables/services-datatable/servicesDatatable.html b/app/directives/ui/datatables/services-datatable/servicesDatatable.html index 82b9c97d3..cf94c0f6a 100644 --- a/app/directives/ui/datatables/services-datatable/servicesDatatable.html +++ b/app/directives/ui/datatables/services-datatable/servicesDatatable.html @@ -108,7 +108,7 @@ - +