Skip to content

Instantly share code, notes, and snippets.

@joelstein
Last active June 15, 2016 20:19
Show Gist options
  • Save joelstein/135a5de77cb8de0626ac685dd6521d56 to your computer and use it in GitHub Desktop.
Save joelstein/135a5de77cb8de0626ac685dd6521d56 to your computer and use it in GitHub Desktop.
Angular directive to blur field on enter
angular.module('enterBlur', [])
// Blurs element when enter is pressed.
.directive('enterBlur', function($timeout) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$timeout(function() {
Drupal.attachBehaviors(element);
});
}
}
})
;
<input type="text" placeholder="Search Terms" ng-model="query" autofocus enter-blur>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment