I'm having trouble twart bootstrap hints not to be removed from the DOM element when using pjax in a Rails application. For example, when I hang up an item using a tooltip, then click on a link to another page, the tooltip will freeze. My current solution for removing 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 / efficient way to do this?
source share