From 56f624a26357b9ec37350ca5a8087930f456719c Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sat, 20 Jul 2013 20:44:58 +0200 Subject: [PATCH] fix(popover): don't unbind event handlers created by other directives Closes #456 --- src/popover/test/popoverSpec.js | 22 ++++++++++++++++++++++ src/tooltip/tooltip.js | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/popover/test/popoverSpec.js b/src/popover/test/popoverSpec.js index b7c5b34ad7..5f1fdc7f05 100644 --- a/src/popover/test/popoverSpec.js +++ b/src/popover/test/popoverSpec.js @@ -44,6 +44,28 @@ describe('popover', function() { elm.trigger( 'click' ); expect( elmScope.tt_isOpen ).toBe( false ); })); + + it('should not unbind event handlers created by other directives - issue 456', inject( function( $compile ) { + + scope.click = function() { + scope.clicked = !scope.clicked; + }; + + elmBody = angular.element( + '
' + ); + $compile(elmBody)(scope); + scope.$digest(); + + elm = elmBody.find('input'); + + elm.trigger( 'mouseenter' ); + elm.trigger( 'mouseleave' ); + expect(scope.clicked).toBeFalsy(); + + elm.click(); + expect(scope.clicked).toBeTruthy(); + })); }); diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 5504e581f3..a8e57669a2 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -276,8 +276,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) }); attrs.$observe( prefix+'Trigger', function ( val ) { - element.unbind( triggers.show ); - element.unbind( triggers.hide ); + element.unbind( triggers.show, showTooltipBind ); + element.unbind( triggers.hide, hideTooltipBind ); triggers = setTriggers( val );