Last active
June 15, 2016 20:19
-
-
Save joelstein/135a5de77cb8de0626ac685dd6521d56 to your computer and use it in GitHub Desktop.
Angular directive to blur field on enter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} | |
} | |
}) | |
; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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