@@ -194,6 +194,7 @@ return $.widget( "ui.tooltip", {
194
194
} ) ;
195
195
}
196
196
197
+ this . _registerCloseHandlers ( event , target ) ;
197
198
this . _updateContent ( target , event ) ;
198
199
} ,
199
200
@@ -208,13 +209,16 @@ return $.widget( "ui.tooltip", {
208
209
}
209
210
210
211
content = contentOption . call ( target [ 0 ] , function ( response ) {
211
- // ignore async response if tooltip was closed already
212
- if ( ! target . data ( "ui-tooltip-open" ) ) {
213
- return ;
214
- }
212
+
215
213
// IE may instantly serve a cached response for ajax requests
216
214
// delay this call to _open so the other call to _open runs first
217
215
that . _delay ( function ( ) {
216
+
217
+ // Ignore async response if tooltip was closed already
218
+ if ( ! target . data ( "ui-tooltip-open" ) ) {
219
+ return ;
220
+ }
221
+
218
222
// jQuery creates a special event for focusin when it doesn't
219
223
// exist natively. To improve performance, the native event
220
224
// object is reused and the type is changed. Therefore, we can't
@@ -232,7 +236,7 @@ return $.widget( "ui.tooltip", {
232
236
} ,
233
237
234
238
_open : function ( event , target , content ) {
235
- var tooltipData , tooltip , events , delayedShow , a11yContent ,
239
+ var tooltipData , tooltip , delayedShow , a11yContent ,
236
240
positionOption = $ . extend ( { } , this . options . position ) ;
237
241
238
242
if ( ! content ) {
@@ -314,8 +318,10 @@ return $.widget( "ui.tooltip", {
314
318
}
315
319
316
320
this . _trigger ( "open" , event , { tooltip : tooltip } ) ;
321
+ } ,
317
322
318
- events = {
323
+ _registerCloseHandlers : function ( event , target ) {
324
+ var events = {
319
325
keyup : function ( event ) {
320
326
if ( event . keyCode === $ . ui . keyCode . ESCAPE ) {
321
327
var fakeEvent = $ . Event ( event ) ;
@@ -329,7 +335,7 @@ return $.widget( "ui.tooltip", {
329
335
// tooltips will handle this in destroy.
330
336
if ( target [ 0 ] !== this . element [ 0 ] ) {
331
337
events . remove = function ( ) {
332
- this . _removeTooltip ( tooltip ) ;
338
+ this . _removeTooltip ( this . _find ( target ) . tooltip ) ;
333
339
} ;
334
340
}
335
341
@@ -350,6 +356,12 @@ return $.widget( "ui.tooltip", {
350
356
351
357
// The tooltip may already be closed
352
358
if ( ! tooltipData ) {
359
+
360
+ // We set ui-tooltip-open immediately upon open (in open()), but only set the
361
+ // additional data once there's actually content to show (in _open()). So even if the
362
+ // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
363
+ // the period between open() and _open().
364
+ target . removeData ( "ui-tooltip-open" ) ;
353
365
return ;
354
366
}
355
367
0 commit comments