4

I am creating an icon in javascript with tooltip.

var icon = '&nbsp;&nbsp;<a class="icon-ok" data-type="reftooltip" title="Save" style="cursor: pointer"></a>';

this icon is displayed and removed dynamically. When I am removing this icon dynamically from javascript by using below code:

success: function(){
//other code//
saveparents.parent().parent().find('a.icon-ok').remove();
//other code//
}

icon is getting removed but tooltip "Save" is still displayed on UI. When I refresh the page, it disappears. But I want it to remove as soon as icon-ok gets removed.

Also I debugged in firebug and found that a div class for tooltip is being created in html page

<html><body>
<div ...................>... </div> 
<div class="tooltip fade top in" style="top: 156.5px; left: 256.667px; display: block;">
   <div class="tooltip-arrow"></div>
   <div class="tooltip-inner">Save</div>
</div>
</body></html>

From firebug I can remove this div by right clicking on deletenode. It successfully removes from UI as well. So I think if I do this using javascript code, it should be removed.

But I don't know what code to put in success function to delete that div class tooltip fade top in. I need help here.

5 Answers 5

7

You should probably have to remove tha actual tooltip as well:

$('body>.tooltip').remove();

Or even better, use your tooltip's native remove function.

Sign up to request clarification or add additional context in comments.

Comments

5

The title attribute becomes the tool-tip text in some browsers. Remove that (either directly, or using Javascript) and it should go away.

http://www.w3.org/TR/WCAG20-TECHS/H33.html

Some graphical user agents will display a tool tip when the mouse hovers above an anchor element containing a title attribute.

Comments

3

I guess it's worth to try:

success: function(){
 //other code//
   ('a.icon-ok').removeAttr("title");
 //other code//
}

EDIT:

I read again your question:

But I don't know what code to put in success function to delete that div class tooltip fade top in. I need help here.

try this way:

success: function(){
 //other code//
   ('div').removeClass("tooltip fade top in"); //<-- costumize your selector
 //other code//
}

good luck !!

3 Comments

@Charlie: it still didnt work.. but i got the solution.. thanks :)
Congrats ! . why dont you just create an answer? maybe useful for others. :)
works when removing "title" as well as "data-original-title" attributes
2

I've tried all these answer, but what worked for me is this,

$("#id").tooltip( "destroy" );

Or you can also use

$("#id").tooltip( "close" );

But, I prefer the first one.

Comments

1

Thanks all for your valuable inputs!! I added this line in success() function and it worked

$("[class='tooltip fade top in']").remove();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.