aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/tooltip/methods.js14
-rw-r--r--ui/widgets/tooltip.js24
2 files changed, 29 insertions, 9 deletions
diff --git a/tests/unit/tooltip/methods.js b/tests/unit/tooltip/methods.js
index e98d1b9ed..6e0af2eb4 100644
--- a/tests/unit/tooltip/methods.js
+++ b/tests/unit/tooltip/methods.js
@@ -94,6 +94,20 @@ QUnit.test( "enable/disable", function( assert ) {
$.fx.off = false;
} );
+QUnit.test( "enable/disable delegated", function( assert ) {
+ assert.expect( 1 );
+ var element = $( "#qunit-fixture" ).tooltip();
+ var tooltipped = $( "#tooltipped1" );
+
+ element.tooltip( "disable" );
+ element.tooltip( "enable" );
+
+ tooltipped.trigger( "mouseover" );
+ assert.equal( $( ".ui-tooltip" ).length, 1, "open" );
+
+ element.tooltip( "destroy" );
+} );
+
QUnit.test( "widget", function( assert ) {
assert.expect( 2 );
var element = $( "#tooltipped1" ).tooltip(),
diff --git a/ui/widgets/tooltip.js b/ui/widgets/tooltip.js
index 94021092a..a8f45bc87 100644
--- a/ui/widgets/tooltip.js
+++ b/ui/widgets/tooltip.js
@@ -114,6 +114,8 @@ $.widget( "ui.tooltip", {
} )
.appendTo( this.document[ 0 ].body );
this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
+
+ this.disabledTitles = $( [] );
},
_setOption: function( key, value ) {
@@ -143,25 +145,29 @@ $.widget( "ui.tooltip", {
} );
// Remove title attributes to prevent native tooltips
- this.element.find( this.options.items ).addBack().each( function() {
- var element = $( this );
- if ( element.is( "[title]" ) ) {
- element
- .data( "ui-tooltip-title", element.attr( "title" ) )
- .removeAttr( "title" );
- }
- } );
+ this.disabledTitles = this.disabledTitles.add(
+ this.element.find( this.options.items ).addBack()
+ .filter( function() {
+ var element = $( this );
+ if ( element.is( "[title]" ) ) {
+ return element
+ .data( "ui-tooltip-title", element.attr( "title" ) )
+ .removeAttr( "title" );
+ }
+ } )
+ );
},
_enable: function() {
// restore title attributes
- this.element.find( this.options.items ).addBack().each( function() {
+ this.disabledTitles.each( function() {
var element = $( this );
if ( element.data( "ui-tooltip-title" ) ) {
element.attr( "title", element.data( "ui-tooltip-title" ) );
}
} );
+ this.disabledTitles = $( [] );
},
open: function( event ) {