We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2e688e3 commit 9daf019Copy full SHA for 9daf019
dist/angular-ui-tree.js
@@ -923,12 +923,19 @@
923
element.bind('touchend touchcancel mouseup',function(){$timeout.cancel(dragTimer);});
924
};
925
bindDrag();
926
-
927
- angular.element($window.document.body).bind("keydown", function(e) {
928
- if (e.keyCode == 27) {
929
- scope.$$apply = false;
930
- dragEnd(e);
931
- }
+
+ var keydownHandler = function(e) {
+ if (e.keyCode == 27) {
+ scope.$$apply = false;
+ dragEnd(e);
+ }
932
+ };
933
934
+ angular.element($window.document.body).bind("keydown", keydownHandler);
935
936
+ //unbind handler that retains scope
937
+ scope.$on('$destroy', function () {
938
+ angular.element($window.document.body).unbind("keydown", keydownHandler);
939
});
940
}
941
0 commit comments