1

The cluetip is displaying an empty "div" if title is empty. How to disable the cluetip when title is empty?

jQuery:

$(document).ready(function () {
        $('a.myClass').cluetip({
            splitTitle: '|',
            showTitle: false,                
            width: 400,
            tracking:true
        });
    });

Html:

<a class="myClass" title="" >Sample Text</a>
<a class="myClass" title="Samle Title" >Sample Text2</a>

When title is present the cluetip is displaying correctly. But when title is empty the cluetip should not be displayed(currently displaying an empty div). How to do it?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Dukhabandhu Sahoo
  • 1,394
  • 1
  • 22
  • 44

2 Answers2

2

Simply bind to anchors which have a title (or a non-empty one):

   // with title attribute present
   $('a[title].myClass').cluetip({
        splitTitle: '|',
        showTitle: false,                
        width: 400,
        tracking:true
    });

   // with an non-empty title
   $('a[title!=""].myClass').cluetip({
        splitTitle: '|',
        showTitle: false,                
        width: 400,
        tracking:true
    });
karim79
  • 339,989
  • 67
  • 413
  • 406
1

Filter out the anchors with no title or empty title using the filter function

$('a.myClass').filter(function() {
    return this.title !== '';
})​.cluetip({
    splitTitle: '|',
    showTitle: false,                
    width: 400,
    tracking:true
});

http://jsfiddle.net/a9ECE/

wirey00
  • 33,517
  • 7
  • 54
  • 65