Skip to content

Commit

Permalink
fix(tooltip): evaluate appendToBody on init
Browse files Browse the repository at this point in the history
This wasn't working properly with the location change code
(lines 305-314) because the observe call happens asynchronously after
the linking function has completed.

Hence, the locationChangeSuccess wasn't being set up unless the global
tooltip option's appendToBody option was set to true.

Closes angular-ui#2921
  • Loading branch information
chrisirhc authored and Oron Nadiv committed Nov 18, 2014
1 parent 9ad6550 commit 4fbb9d5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
* Returns the actual instance of the $tooltip service.
* TODO support multiple triggers
*/
this.$get = [ '$window', '$compile', '$timeout', '$parse', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $parse, $document, $position, $interpolate ) {
this.$get = [ '$window', '$compile', '$timeout', '$document', '$position', '$interpolate', function ( $window, $compile, $timeout, $document, $position, $interpolate ) {
return function $tooltip ( type, prefix, defaultTriggerShow ) {
var options = angular.extend( {}, defaultOptions, globalOptions );

Expand Down Expand Up @@ -299,9 +299,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
var animation = scope.$eval(attrs[prefix + 'Animation']);
scope.tt_animation = angular.isDefined(animation) ? !!animation : options.animation;

attrs.$observe( prefix+'AppendToBody', function ( val ) {
appendToBody = angular.isDefined( val ) ? $parse( val )( scope ) : appendToBody;
});
var appendToBodyVal = scope.$eval(attrs[prefix + 'AppendToBody']);
appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;

// if a tooltip is attached to <body> we need to remove it on
// location change as its parent scope will probably not be destroyed
Expand Down

0 comments on commit 4fbb9d5

Please sign in to comment.