diff --git a/angucomplete.js b/angucomplete.js index 7a42bf0..896fc44 100644 --- a/angucomplete.js +++ b/angucomplete.js @@ -23,9 +23,12 @@ angular.module('angucomplete', [] ) "localData": "=localdata", "searchFields": "@searchfields", "minLengthUser": "@minlength", - "matchClass": "@matchclass" + "matchClass": "@matchclass", + "onBlurEvent" :"@onBlurEvent", + "onFocusEvent": "@onFocusEvent", + "autocomplete": "@autocomplete" }, - template: '
Searching...
No results found
{{ result.title }}
{{result.description}}
', + template: '
Searching...
No results found
{{ result.title }}
{{result.description}}
', link: function($scope, elem, attrs) { $scope.lastSearchTerm = null; @@ -142,16 +145,24 @@ angular.module('angucomplete', [] ) } } - $scope.hideResults = function() { + $scope.onBlur = function() { $scope.hideTimer = $timeout(function() { $scope.showDropdown = false; }, $scope.pause); + + if($scope.onBlurEvent) { + $scope.$emit($scope.onBlurEvent); + } }; - $scope.resetHideResults = function() { + $scope.onFocus = function() { if($scope.hideTimer) { $timeout.cancel($scope.hideTimer); }; + + if($scope.onFocusEvent) { + $scope.$emit($scope.onFocusEvent); + } }; $scope.hoverRow = function(index) {