aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.tooltip.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-08-31 15:38:21 -0400
committerScott González <scott.gonzalez@gmail.com>2012-08-31 15:38:21 -0400
commitdee7c8bd4493826e13b78b2d702947e6f4ad966e (patch)
tree19b769f7076c19fd23df650799b241c05aefb8c1 /ui/jquery.ui.tooltip.js
parentc135fc18a392476e5163376aed85525a80575e24 (diff)
downloadjquery-ui-dee7c8bd4493826e13b78b2d702947e6f4ad966e.tar.gz
jquery-ui-dee7c8bd4493826e13b78b2d702947e6f4ad966e.zip
Tooltip: Update open tooltips if the content option changes. Fixes #8544 - Unable to update tooltip content dynamically.
Diffstat (limited to 'ui/jquery.ui.tooltip.js')
-rw-r--r--ui/jquery.ui.tooltip.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index 9f0a8a810..f94d9715c 100644
--- a/ui/jquery.ui.tooltip.js
+++ b/ui/jquery.ui.tooltip.js
@@ -73,13 +73,22 @@ $.widget( "ui.tooltip", {
},
_setOption: function( key, value ) {
+ var that = this;
+
if ( key === "disabled" ) {
this[ value ? "_disable" : "_enable" ]();
this.options[ key ] = value;
// disable element style changes
return;
}
+
this._super( key, value );
+
+ if ( key === "content" ) {
+ $.each( this.tooltips, function( id, element ) {
+ that._updateContent( element );
+ });
+ }
},
_disable: function() {
@@ -114,9 +123,7 @@ $.widget( "ui.tooltip", {
},
open: function( event ) {
- var content,
- that = this,
- target = $( event ? event.target : this.element )
+ var target = $( event ? event.target : this.element )
.closest( this.options.items );
// No element to show a tooltip for
@@ -140,6 +147,13 @@ $.widget( "ui.tooltip", {
target.data( "tooltip-open", true );
+ this._updateContent( target, event );
+ },
+
+ _updateContent: function( target, event ) {
+ var content,
+ that = this;
+
content = this.options.content.call( target[0], function( response ) {
// ignore async response if tooltip was closed already
if ( !target.data( "tooltip-open" ) ) {
@@ -147,12 +161,12 @@ $.widget( "ui.tooltip", {
}
// IE may instantly serve a cached response for ajax requests
// delay this call to _open so the other call to _open runs first
- setTimeout(function() {
- that._open( event, target, response );
- }, 1 );
+ that._delay(function() {
+ this._open( event, target, response );
+ });
});
if ( content ) {
- that._open( event, target, content );
+ this._open( event, target, content );
}
},