From e242868f563fa244c6cbe04a421cb1734a322024 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 31 Aug 2012 15:41:45 -0400 Subject: [PATCH] Tooltip: Allow strings for content option. --- tests/unit/tooltip/tooltip_options.js | 10 ++++++++++ ui/jquery.ui.tooltip.js | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index 561f3ffe5..db193e8fa 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -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, diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index f94d9715c..bd04861e2 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -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; -- 2.39.5