@@ -35,6 +35,9 @@ $.widget( "ui.tooltip", {
35
35
mouseover : "open" ,
36
36
focusin : "open"
37
37
} ) ;
38
+
39
+ // IDs of generated tooltips, needed for destroy
40
+ this . tooltips = { } ;
38
41
} ,
39
42
40
43
_setOption : function ( key , value ) {
@@ -114,7 +117,8 @@ $.widget( "ui.tooltip", {
114
117
} ,
115
118
116
119
close : function ( event ) {
117
- var target = $ ( event ? event . currentTarget : this . element ) ;
120
+ var that = this ,
121
+ target = $ ( event ? event . currentTarget : this . element ) ;
118
122
target . attr ( "title" , target . data ( "tooltip-title" ) ) ;
119
123
120
124
if ( this . options . disabled ) {
@@ -127,6 +131,7 @@ $.widget( "ui.tooltip", {
127
131
tooltip . stop ( true ) ;
128
132
this . _hide ( tooltip , this . options . hide , function ( ) {
129
133
$ ( this ) . remove ( ) ;
134
+ delete that [ this . id ] ;
130
135
} ) ;
131
136
132
137
// TODO: why isn't click unbound here?
@@ -136,9 +141,10 @@ $.widget( "ui.tooltip", {
136
141
} ,
137
142
138
143
_tooltip : function ( ) {
139
- var tooltip = $ ( "<div>" )
144
+ var id = "ui-tooltip-" + increments ++ ,
145
+ tooltip = $ ( "<div>" )
140
146
. attr ( {
141
- id : "ui-tooltip-" + increments ++ ,
147
+ id : id ,
142
148
role : "tooltip"
143
149
} )
144
150
. addClass ( "ui-tooltip ui-widget ui-corner-all ui-widget-content" +
@@ -147,12 +153,20 @@ $.widget( "ui.tooltip", {
147
153
. addClass ( "ui-tooltip-content" )
148
154
. appendTo ( tooltip ) ;
149
155
tooltip . appendTo ( document . body ) ;
156
+ this . tooltips [ id ] = true ;
150
157
return tooltip ;
151
158
} ,
152
159
153
160
_find : function ( target ) {
154
161
var id = target . attr ( "aria-describedby" ) ;
155
162
return id ? $ ( "#" + id ) : $ ( ) ;
163
+ } ,
164
+
165
+ destroy : function ( ) {
166
+ $ . each ( this . tooltips , function ( id ) {
167
+ $ ( "#" + id ) . remove ( ) ;
168
+ } ) ;
169
+ this . _super ( "destroy" ) ;
156
170
}
157
171
} ) ;
158
172
0 commit comments