OjamaYellow
OjamaYellow

Reputation: 969

Don't show jquery tooltip in specific cases

I have a table and for one column I want to have a tooltip in each row. So all cells in one column have specific class, 'cell1' so I made tooltip with jquery:

$(table).uitooltip({
  items: 'cell1',
  content: 'some content'
}); 

What I want to do is to not show the tooltip in case the cell value is empty. So

$('.cell1').html() == ""

Is it possible to show jquery tooltip only in some cases?

Upvotes: 2

Views: 139

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337560

To achieve this provide a function to content which returns the text to be shown in the tooltip. In cases where you do not want to show the tooltip at all, return null.

$(table).uitooltip({
  items: 'cell1',
  content: function() {
    return $(this).html().trim() !== '' ? 'some content' : null;
  }
}); 

Upvotes: 3

Related Questions