0

I am using a Primefaces Global Tooltip. I set the title during runtime.

Apparently the title is deleted by Primefaces and stored in data. Got this code from Primefaces on Github.

var title = element.attr('title');
if (title) {
   element.data('tooltip', title).removeAttr('title');
}

My question now is how can I stop showing the tooltip for certain elements? Tried to overwrite the title attribute on runtime with an empty value. But this not working, since primefaces check for if (title).

My Case:

  1. Show an tooltip if the elment has an overflow. (Already working)

  2. Don´t show the tooltip if the element has no overflow. (Working partly) - if the tooltip was shown once, there is no way to stop showing it. Since the title value get saved somewhere else. Where to replace it with null or an empty string?

  • @JasperdeVries There is any option to find out where the value is saved and change it to an empty string while runtime? So nothing is shown? – reckless1337 Jun 01 '22 at 09:15

2 Answers2

1

Your best option here is to use the globalSelector attribute. It is a jQuery selector for the global tooltip and defaults to a,:input,:button. So you can narrow down on what elements the global tooltip is applied.

See also:

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • I´m using a global Tooltip. But i want to change the text of the tooltip by javascript. My goal is to hide or show the tooltip for the hovered element by a condition which i have in javascript. Where the global tooltip save the value? I noticed, in devtools from browser, when i click on the element -> Properties there is a JQuery3600383838938389 with the value of the tooltip, but no idea how to access it by javascript / JQuery. – reckless1337 Jun 01 '22 at 10:10
  • You probably want to monkey patch the widget https://stackoverflow.com/questions/36594082/monkeypatching-primefaces-widgets-extend-override – Jasper de Vries Jun 01 '22 at 14:54
0

Found out how to access the tooltip value.

$(element).data('tooltip')

Tried before:

element.data('tooltip');

Which not worked.