diff --git a/js/pages/backoffice/toolbox.js b/js/pages/backoffice/toolbox.js index 256a6fc88..df7f11a1a 100644 --- a/js/pages/backoffice/toolbox.js +++ b/js/pages/backoffice/toolbox.js @@ -70,7 +70,7 @@ const CombodoBackofficeToolbox = { // Processing $(document).ready(function(){ // Enable tooltips based on existing HTML markup, won't work on markup added dynamically after DOM ready (AJAX, ...) - $('[data-tooltip-content]').each(function(){ + $('[data-tooltip-content]:not([data-tooltip-instanciated="true"])').each(function(){ CombodoGlobalToolbox.InitTooltipFromMarkup($(this)); }); }); \ No newline at end of file diff --git a/js/utils.js b/js/utils.js index 40681a645..e7ca41882 100644 --- a/js/utils.js +++ b/js/utils.js @@ -813,15 +813,22 @@ const CombodoGlobalToolbox = { * * Note: Content SHOULD be HTML entity encoded to avoid markup breaks (eg. when using a double quote in a sentence) * - * @param oElem + * @param {Object} oElem The jQuery object representing the element + * @param {boolean} bForce When set to true, tooltip will be instanciate even if one already exists, overwritting it. * @constructor */ - InitTooltipFromMarkup: function(oElem) + InitTooltipFromMarkup: function(oElem, bForce = false) { const oOptions = { allowHTML: true, // Always true so line breaks can work. Don't worry content will be sanitized. }; + // First, check if the tooltip isn't already instanciated + if((oElem.attr('data-tooltip-instanciated') === 'true') && (bForce === false)) + { + return false; + } + // Content must be reworked before getting into the tooltip // - Should we enable HTML content or keep text as is const bEnableHTML = oElem.attr('data-tooltip-html-enabled') === 'true'; @@ -870,5 +877,8 @@ const CombodoGlobalToolbox = { ]; tippy(oElem[0], oOptions); + + // Mark tooltip as instanciated + oElem.attr('data-tooltip-instanciated', 'true'); } }; \ No newline at end of file