diff options
Diffstat (limited to 'ui/jquery.ui.tooltip.js')
-rw-r--r-- | ui/jquery.ui.tooltip.js | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 9f0a8a810..f38379f21 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -6,6 +6,8 @@ * Released under the MIT license. * http://jquery.org/license * + * http://api.jqueryui.com/tooltip/ + * * Depends: * jquery.ui.core.js * jquery.ui.widget.js @@ -73,13 +75,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 +125,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,19 +149,31 @@ $.widget( "ui.tooltip", { target.data( "tooltip-open", true ); - content = this.options.content.call( target[0], function( response ) { + this._updateContent( target, event ); + }, + + _updateContent: function( target, event ) { + var content, + contentOption = this.options.content, + that = this; + + if ( typeof contentOption === "string" ) { + return this._open( event, target, contentOption ); + } + + content = contentOption.call( target[0], function( response ) { // ignore async response if tooltip was closed already if ( !target.data( "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 - 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 ); } }, |