diff --git a/tooltipsy.source.js b/tooltipsy.source.js index 7b48958..3094051 100644 --- a/tooltipsy.source.js +++ b/tooltipsy.source.js @@ -191,10 +191,17 @@ }, destroy: function () { - if (this.$tipsy) { + if(this.$tipsy) { this.$tipsy.remove(); - $.removeData(this.$el, 'tooltipsy'); } + else { + window.clearTimeout(this.delaytimer); + this.delaytimer=null; + } + this.$el.removeData('tooltipsy'); + this.$el.off(this.settings.showEvent); + this.$el.off(this.settings.hideEvent); + this.$el.attr('title',this.title); }, defaults: { @@ -220,5 +227,28 @@ new $.tooltipsy(this, options); }); }; + + /** + * What is "enhanced"?: initialize only if element was not initialized, useful for ajax-loaded elements + */ + $.fn.tooltipsyEnhancedInit = function() { + return this.each(function() { + if( $( this ).data('tooltipsy') === undefined ){ + $( this ).tooltipsy(); + } + }); + }; + + /** + * What is "enhanced"?: destroy only if element was initialized, useful for ajax-loaded elements + */ + $.fn.tooltipsyEnhancedDestroy = function() { + return this.each(function() { + if( $( this ).data('tooltipsy') !== undefined ){ + $( this ).data('tooltipsy').hide(); + $( this ).data('tooltipsy').destroy(); + } + }); + }; })(jQuery);