I've had some issues with the twitter bootstrap tooltips not being removed from the DOM element when using pjax on a Rails app. For example, when I mouseover an element with a tooltip, then click a link to another page, the tooltip is frozen. My current solution to removing the tooltips is as follows:
App.Utils.Tooltip = {
triggerAll: function(element) {
if (element.data('tooltip-loaded') == true) { return; }
element.data('tooltip-loaded', true).tooltip().trigger('mouseover');
},
destroyAll: function() {
var tooltips = ($('[rel=tooltip]').get());
$.each(tooltips, function() {
$(this).tooltip('destroy');
});
}
};
$(document).on('mouseover', '[rel=tooltip]', function() {
App.Utils.Tooltip.triggerAll($(this));
});
$(document).on('pjax:beforeSend', function() {
App.Utils.Tooltip.destroyAll();
});
Is there a more efficient / effective way to do this?