How to disable cluetip when title is empty?

149 views Asked by At

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?

2

There are 2 answers

0
wirey00 On BEST ANSWER

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/

1
karim79 On

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
    });