@@ -108,8 +108,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
108
108
return {
109
109
restrict : 'EA' ,
110
110
scope : true ,
111
- link : function link ( scope , element , attrs ) {
112
- var tooltip = $compile ( template ) ( scope ) ;
111
+ compile : function ( tElem , tAttrs ) {
112
+ var tooltipLinker = $compile ( template ) ;
113
+
114
+ return function link ( scope , element , attrs ) {
115
+ var tooltip ;
113
116
var transitionTimeout ;
114
117
var popupTimeout ;
115
118
var appendToBody = angular . isDefined ( options . appendToBody ) ? options . appendToBody : false ;
@@ -154,6 +157,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
154
157
ttHeight ,
155
158
ttPosition ;
156
159
160
+ // There can only be one tooltip element per directive shown at once.
161
+ removeTooltip ( ) ;
162
+ tooltip = tooltipLinker ( scope ) ;
163
+
157
164
// Don't show empty tooltips.
158
165
if ( ! scope . tt_content ) {
159
166
return ;
@@ -234,11 +241,16 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
234
241
// need to wait for it to expire beforehand.
235
242
// FIXME: this is a placeholder for a port of the transitions library.
236
243
if ( scope . tt_animation ) {
237
- transitionTimeout = $timeout ( function ( ) {
238
- tooltip . remove ( ) ;
239
- } , 500 ) ;
244
+ transitionTimeout = $timeout ( removeTooltip , 500 ) ;
240
245
} else {
246
+ removeTooltip ( ) ;
247
+ }
248
+ }
249
+
250
+ function removeTooltip ( ) {
251
+ if ( tooltip ) {
241
252
tooltip . remove ( ) ;
253
+ tooltip = null ;
242
254
}
243
255
}
244
256
@@ -313,10 +325,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap
313
325
$timeout . cancel ( transitionTimeout ) ;
314
326
$timeout . cancel ( popupTimeout ) ;
315
327
unregisterTriggers ( ) ;
316
- tooltip . remove ( ) ;
317
- tooltip . unbind ( ) ;
318
- tooltip = null ;
328
+ removeTooltip ( ) ;
319
329
} ) ;
330
+ } ;
320
331
}
321
332
} ;
322
333
} ;
0 commit comments