Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overwrite twitter bootstrap tooltip?

I'm using tooltips from Twitter Bootstrap package to show items information on the page. Sometimes information is changed, and needs to be updated in the tooltip. I tried simply to reinitialize tooltip with new title:

$('#selector').tooltip({ title: 'new text'});

However tooltip's title doesn't get changed with the new text. It remains the same as it was set initially. Any ideas why, and is there any work around? Thanks!

like image 800
bbbonthemoon Avatar asked Jun 26 '12 19:06

bbbonthemoon


People also ask

How do I change text tooltip in bootstrap?

Useful if you need to change a tooltip's text after it has been initialized: $(this). tooltip('hide') . attr('data-original-title', 'new text') .

How do I change dynamic value tooltip?

Drag the calculated field to the appropriate tooltip and you'll see an ATTR dimension pill with a tooltip logo in the Marks card. Insert the ATTR budget and adjusted inflated gross calculated fields into its corresponding tooltip as seen in Image 6. After that, you're dynamic tooltip should work!


2 Answers

You can't override the tooltip object once you have initialized it on one element. But you can delete it and do it again.

Try deleting and then reinitialize the tooltip with all your options (if you had any).

$('#selector').data('bs.tooltip',false)          // Delete the tooltip
              .tooltip({ title: 'new text'});

There may be a need to remove the listeners, but it works like that.


Before TWBS v3 you would not need the bs namespace giving : data('tooltip')

like image 117
Sherbrow Avatar answered Oct 13 '22 20:10

Sherbrow


This technique did not work for me so I found an answer, hidden in one of the comments of a similar question.

the cleanest way to update the display text of the tooltip

$(element).attr('title', 'NEW_TITLE').tooltip('fixTitle').tooltip('show');

Thank you to lukmdo

like image 32
George Albertyn Avatar answered Oct 13 '22 21:10

George Albertyn