Skip to content

Commit e242868

Browse files
committed
Tooltip: Allow strings for content option.
1 parent dee7c8b commit e242868

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/unit/tooltip/tooltip_options.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ test( "content: change while open", function() {
6565
element.tooltip( "open" );
6666
});
6767

68+
test( "content: string", function() {
69+
expect( 1 );
70+
var element = $( "#tooltipped1" ).tooltip({
71+
content: "just a string",
72+
open: function( event, ui ) {
73+
equal( ui.tooltip.text(), "just a string" );
74+
}
75+
}).tooltip( "open" );
76+
});
77+
6878
test( "items", function() {
6979
expect( 2 );
7080
var event,

ui/jquery.ui.tooltip.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,14 @@ $.widget( "ui.tooltip", {
152152

153153
_updateContent: function( target, event ) {
154154
var content,
155+
contentOption = this.options.content,
155156
that = this;
156157

157-
content = this.options.content.call( target[0], function( response ) {
158+
if ( typeof contentOption === "string" ) {
159+
return this._open( event, target, contentOption );
160+
}
161+
162+
content = contentOption.call( target[0], function( response ) {
158163
// ignore async response if tooltip was closed already
159164
if ( !target.data( "tooltip-open" ) ) {
160165
return;

0 commit comments

Comments
 (0)