Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit 47a99e8

Browse files
committed
Merge pull request #38 from fedyk/master
Improve destroy logic
2 parents 07d69ec + b4f15cc commit 47a99e8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/js/angular-tooltips.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,20 @@
277277
}
278278
};
279279

280-
//destroy the tooltip when the directive is destroyed
281-
$scope.$on('$destroy', function() {
282-
theTooltip.remove();
283-
});
284-
285-
angular.element($window).bind('resize', function onResize() {
286-
280+
function onResize() {
287281
$scope.hideTooltip();
288282
$scope.initTooltip(originSide);
283+
}
284+
285+
angular.element($window).bind('resize', onResize);
286+
287+
// destroy the tooltip when the directive is destroyed
288+
// unbind all dom event handlers
289+
$scope.$on('$destroy', function() {
290+
angular.element($window).unbind('resize', onResize);
291+
theTooltip.unbind(showTriggers);
292+
theTooltip.unbind(hideTriggers);
293+
theTooltip.remove();
289294
});
290295
}
291296
};

0 commit comments

Comments
 (0)