]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip: Allow strings for content option.
authorScott González <scott.gonzalez@gmail.com>
Fri, 31 Aug 2012 19:41:45 +0000 (15:41 -0400)
committerScott González <scott.gonzalez@gmail.com>
Fri, 31 Aug 2012 19:41:45 +0000 (15:41 -0400)
tests/unit/tooltip/tooltip_options.js
ui/jquery.ui.tooltip.js

index 561f3ffe5b55d177415b79a741be292d943656f4..db193e8fa5320e97aab72ecbefc148f4e1784ca4 100644 (file)
@@ -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,
index f94d9715c7591d899474d714ce1525eedca8d72b..bd04861e284b2588c87e753fe3f6215da63959f9 100644 (file)
@@ -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;