window.initTooltip = (element) => { $(element).tooltip({ container: 'body', delay: { show: 300, hide: 150 }, trigger: 'hover', placement: (_, source) => { const position = $(source).attr('data-tooltip-placement'); return position || 'top'; }, template: `` }); }; window.destroyTooltip = (element) => { $(element).tooltip('destroy'); }; $(document).on('turbolinks:load', function() { $(document).find('[data-render-tooltip]').each(function() { window.initTooltip(this); }) });