7

I'm using qTip2 here, and need the ability to refresh the content of the tooltip while it is still active. The elements with the tooltip have a click event that does some calculations that can change what I want to be displayed in the tooltip.

I have tried calling the 'destroy' method and rebinding the qtip2 after each recalculation, and it works but only after moving the mouse away and bringing it back.

What I want to achieve is to force the currently active tooltip to redraw itself.

Neysor
  • 3,893
  • 11
  • 34
  • 66
andrew
  • 73
  • 1
  • 3

1 Answers1

8

If you look in the documentation, there is a "set" method to change the content:

$('.selector').qtip('option', 'content.text', 'new content'); // Preferred

Is that what you're looking for?


Update: After testing out the api options, they seem to not be working properly, but I've found another method - here is a demo - hover over the tip for 1 sec to see it change.

// make sure you target a specific tip
var qapi = $('#tip1').data('qtip'),
    newtip = 'new tooltip content'
qapi.options.content.text = newtip; // update content stored in options
qapi.elements.content.text(newtip); // update visible tooltip content
qapi.redraw(); // redraw to adjust tooltip borders
Mottie
  • 84,355
  • 30
  • 126
  • 241
  • It sounds like he wants to change the content of the tooltip _while_ the tip is still open. – Sparky Jul 26 '11 at 04:35
  • @Sparky672: Yeah I knew that's what andrew wanted, but after testing it, it doesn't seem to work =( – Mottie Jul 26 '11 at 05:39
  • Actually the top method does work... it wasn't working for me when I used `$(this)` inside of the setTimeout in the demo (DUH) instead of `$('.selector')` so that's why I worked on the alternate method. Either way works, but the first would be the best. – Mottie Jul 26 '11 at 14:02