Skip to content

Commit

Permalink
Tooltip: Allow strings for content option.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Aug 31, 2012
1 parent dee7c8b commit e242868
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/unit/tooltip/tooltip_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ test( "content: change while open", function() {
element.tooltip( "open" );
});

test( "content: string", function() {
expect( 1 );
var element = $( "#tooltipped1" ).tooltip({
content: "just a string",
open: function( event, ui ) {
equal( ui.tooltip.text(), "just a string" );
}
}).tooltip( "open" );
});

test( "items", function() {
expect( 2 );
var event,
Expand Down
7 changes: 6 additions & 1 deletion ui/jquery.ui.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,14 @@ $.widget( "ui.tooltip", {

_updateContent: function( target, event ) {
var content,
contentOption = this.options.content,
that = this;

content = this.options.content.call( target[0], function( response ) {
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;
Expand Down

0 comments on commit e242868

Please sign in to comment.