Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qTip (jQuery plug-in) how can I remove all qtips in my page?

I'm using the jquery-plugin qTip. What's the command to destroy all tooltips in my page ?

I tried:

$('.option img[title], span.taxonomy-image-link-alter img[title]').qtip("destroy");

But it didn't work... Thanks

like image 747
aneuryzm Avatar asked Apr 28 '10 07:04

aneuryzm


4 Answers

I've solved with $(".qtip").remove();

like image 193
aneuryzm Avatar answered Nov 07 '22 09:11

aneuryzm


qTip2 is newer version of this script, but I would just like to point out 1 thing.

$(".qtip").remove();

This piece of code didn't destroy all the tooltips - it simply removed their containers. All the handlers and events attached to objects which invoked the tooltips are still avaiable in browser's memory.

In qTip to delete the tooltip and it's handler scompletely you would have to use:

$(mytooltip).qtip("destroy");

or

$(mytooltip).qtip('api').destroy(); 

In qTip2 however using this:

$(mytooltip).remove();

Would automaticaly call out the api and destroy tooltip and it's handlers completely.

like image 19
biphobe Avatar answered Nov 07 '22 09:11

biphobe


$('.qtip').each(function(){
  $(this).data('qtip').destroy();
})
like image 18
Stewie Avatar answered Nov 07 '22 10:11

Stewie


qtip("destroy") is buggy (version 2.1.1) and doesn't clear everything.

I found this as a proper workaround:

// don't call destroy if not needed
if (element.data("qtip")) {
    // the 'true' makes the difference
    element.qtip("destroy",true);
    // extra cleanup
    element.removeData("hasqtip");
    element.removeAttr("data-hasqtip");
}
like image 12
gamliela Avatar answered Nov 07 '22 09:11

gamliela