-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Tooltip: Register event handlers before content is loaded #1456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,6 +199,7 @@ return $.widget( "ui.tooltip", { | |
}); | ||
} | ||
|
||
this._registerCloseHandlers( event, target ); | ||
this._updateContent( target, event ); | ||
}, | ||
|
||
|
@@ -214,13 +215,16 @@ return $.widget( "ui.tooltip", { | |
} | ||
|
||
content = contentOption.call( target[0], function( response ) { | ||
// ignore async response if tooltip was closed already | ||
if ( !target.data( "ui-tooltip-open" ) ) { | ||
return; | ||
} | ||
|
||
// IE may instantly serve a cached response for ajax requests | ||
// delay this call to _open so the other call to _open runs first | ||
that._delay(function() { | ||
|
||
// Ignore async response if tooltip was closed already | ||
if ( !target.data( "ui-tooltip-open" ) ) { | ||
return; | ||
} | ||
|
||
// jQuery creates a special event for focusin when it doesn't | ||
// exist natively. To improve performance, the native event | ||
// object is reused and the type is changed. Therefore, we can't | ||
|
@@ -238,7 +242,7 @@ return $.widget( "ui.tooltip", { | |
}, | ||
|
||
_open: function( event, target, content ) { | ||
var tooltipData, tooltip, events, delayedShow, a11yContent, | ||
var tooltipData, tooltip, delayedShow, a11yContent, | ||
positionOption = $.extend( {}, this.options.position ); | ||
|
||
if ( !content ) { | ||
|
@@ -316,8 +320,10 @@ return $.widget( "ui.tooltip", { | |
} | ||
|
||
this._trigger( "open", event, { tooltip: tooltip } ); | ||
}, | ||
|
||
events = { | ||
_registerCloseHandlers: function( event, target ) { | ||
var events = { | ||
keyup: function( event ) { | ||
if ( event.keyCode === $.ui.keyCode.ESCAPE ) { | ||
var fakeEvent = $.Event(event); | ||
|
@@ -331,7 +337,7 @@ return $.widget( "ui.tooltip", { | |
// tooltips will handle this in destroy. | ||
if ( target[ 0 ] !== this.element[ 0 ] ) { | ||
events.remove = function() { | ||
this._removeTooltip( tooltip ); | ||
this._removeTooltip( this._find( target ).tooltip ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line was changed from |
||
}; | ||
} | ||
|
||
|
@@ -352,6 +358,12 @@ return $.widget( "ui.tooltip", { | |
|
||
// The tooltip may already be closed | ||
if ( !tooltipData ) { | ||
|
||
// We set ui-tooltip-open immediately upon open (in open()), but only set the | ||
// additional data once there's actually content to show (in _open()). So even if the | ||
// tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in | ||
// the period between open() and _open(). | ||
target.removeData( "ui-tooltip-open" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the key thing that was needed after rebasing. |
||
return; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was untouched.