mouseover: "open",
focusin: "open"
});
+
+ // IDs of generated tooltips, needed for destroy
+ this.tooltips = {};
},
_setOption: function( key, value ) {
},
close: function( event ) {
- var target = $( event ? event.currentTarget : this.element );
+ var that = this,
+ target = $( event ? event.currentTarget : this.element );
target.attr( "title", target.data( "tooltip-title" ) );
if ( this.options.disabled ) {
tooltip.stop( true );
this._hide( tooltip, this.options.hide, function() {
$( this ).remove();
+ delete that[ this.id ];
});
// TODO: why isn't click unbound here?
},
_tooltip: function() {
- var tooltip = $( "<div>" )
+ var id = "ui-tooltip-" + increments++,
+ tooltip = $( "<div>" )
.attr({
- id: "ui-tooltip-" + increments++,
+ id: id,
role: "tooltip"
})
.addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content" +
.addClass( "ui-tooltip-content" )
.appendTo( tooltip );
tooltip.appendTo( document.body );
+ this.tooltips[ id ] = true;
return tooltip;
},
_find: function( target ) {
var id = target.attr( "aria-describedby" );
return id ? $( "#" + id ) : $();
+ },
+
+ destroy: function() {
+ $.each( this.tooltips, function( id ) {
+ $( "#" + id ).remove();
+ });
+ this._super( "destroy" );
}
});