Search code examples
jquerytooltipqtip2

Tooltip content qTip2 jQuery


I´m trying to get this to work but it just want...

The alert alerts the correct content.. any ideas?

    function initToolTip() {
        $('.product').qtip({
            content: $(this).find('.product-info').html(),
            style: 'ui-tooltip-shadow'
         });
         $('.product').on('hover',function(){
            //alert($(this).find('.product-info').html());
         });
    }

Solution

  • Here

    $(this) is not in the context of the .product in the first case..

    $(this) refers to the tooltip object..

    Use the custom function to retrieve that ..

    $('.product').qtip({
                content: {
                   text: function(api) {
                    return $(this).find('.product-info').html() ;
                   }
                },
                style: 'ui-tooltip-shadow'
             });