From 4fd5bf43459df7bdd0ebf070b6137826669f8c5d Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sat, 3 Aug 2013 15:20:50 +0200 Subject: [PATCH] fix(tooltip): correctly handle initial events unbinding Closes #750 --- src/tooltip/tooltip.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 07039dce05..2b65f3a931 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -122,6 +122,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) var $body; var appendToBody = angular.isDefined( options.appendToBody ) ? options.appendToBody : false; var triggers = setTriggers( undefined ); + var hasRegisteredTriggers = false; // By default, the tooltip is not open. // TODO add ability to start tooltip opened @@ -276,8 +277,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) }); attrs.$observe( prefix+'Trigger', function ( val ) { - element.unbind( triggers.show, showTooltipBind ); - element.unbind( triggers.hide, hideTooltipBind ); + + if (hasRegisteredTriggers) { + element.unbind( triggers.show, showTooltipBind ); + element.unbind( triggers.hide, hideTooltipBind ); + } triggers = setTriggers( val ); @@ -287,6 +291,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position' ] ) element.bind( triggers.show, showTooltipBind ); element.bind( triggers.hide, hideTooltipBind ); } + + hasRegisteredTriggers = true; }); attrs.$observe( prefix+'AppendToBody', function ( val ) {