Search code examples
javascriptjqueryjquery-uijquery-tooltip

How to disable a subset of general created jQuery tooltips


We have the current situation that we need to disable some tooltips when an overlay menu opens. Since all tooltips are generally created using $(document).tooltip(), it somehow doesn't work when disabling a subset of the created tooltips, e.g. $('a.special').tooltip('disable').

HTML

<a href="#" title="special tooltip" class="special">Link</a>

JS

$(document).tooltip(); // works :)

$('button').click(function () {
    // -> How can we make this work?
    $('a.special').tooltip('disable'); // doesn't work :(
});

JS-Fiddle

How can we make this work?


Solution

  • Working Demo

    Apply tooltip to all elements using '*' as selector and not document. It initialises tooltip on document object and not elements.

    Use this snippet,

    $('*').tooltip();
    
    $('button').click(function () {
        $('#message').show();
        $('a.special').tooltip('disable');
    });