user4812502
user4812502

Reputation: 157

jQuery to close tooltip in JSF

I am trying to close tooltip using jQuery hide.

On the tooltip, I put a image with onclick event that calls javascript function to hide the tooltip

<img id=... src=... onclick="hideTooltip('formId:tableId:rowIndex:tooltipId')" />

Here is the javascript function

function hideTooltip(elem) {
  var pound = '#';
  jQuery(pound.concat(elem.replace(/:/g, '\\\\:'))).hide('slow');
}

The js function is called as if I put a alert, it will pop up but hide() doesn't work. When I inspect the elements the id of the tooltip is form:table:rowIndex#:tooltipId.

I tried to use widgetVar and it will hide the tooltip but the tooltip shows data based on just the last row and not of each row.

<img ... onclick="PF('widgetVarID').hide()" />

Upvotes: 1

Views: 169

Answers (1)

sam
sam

Reputation: 2033

Your regex is incorrect. The correct format should be '\:'

Replace with pound.concat(elem.replace(/:/g, '\\:'));

You can also use PrimeFaces.escapeClientId().

Check How to use JSF generated HTML element ID with colon ":" in CSS selectors?

Upvotes: 1

Related Questions