Change Content of a Qtip
Asked Answered
S

1

7

I've read the api docs and forums and am trying to change the content of a tooltip after it's been set initially, however it is not working. What am I doing wrong?

HTML:

<p id="666">tooltip</p>

JQUERY

var qconfig = {
 show: 'mouseover',
 hide: { when: 'mouseout', fixed: true },
 position: { my: 'bottom center', at: 'top center', adjust: {y: 8} },
 style: { classes: 'qtip-light qtip-shadow' }
};

$("#666").qtip($.extend(true, qconfig, { content: { text: "before", title: "title is here" }}));
$("#666").qtip('option', 'content.text', 'after');
$("#666").qtip('api').set('content.text', 'another after');[/code]

I would expect the content of the tooltip to be "after" or "another after" but it remains "before". Help please.

JSFiddle is here: http://jsfiddle.net/Af64c/

Sarajane answered 10/9, 2013 at 22:31 Comment(2)
I'm not sure I follow, it seems like you know how to set the tooltip since you did it successfully once there. Here is a fiddle that provides a simplified version but I don't think it answers your question... jsfiddle.net/hfvzDOverflow
Sorry, I want to change the content of the tooltip after it's been set. I updated my question to clarify.Sarajane
D
9

You can change the content like this

$('#666').data('qtip').options.content.text = 'after';

FIDDLE

Dantedanton answered 10/9, 2013 at 23:28 Comment(1)
Thanks @khawer-zeshan, that works! Also, Craig, the developer of qtip2 said that it looks like $("#666").qtip('option', 'content.text', 'after'); should work but is broken in the current stable build (2.1.1) but is fixed in the nightly build at qtip2.com/v/nightly.Sarajane

© 2022 - 2024 — McMap. All rights reserved.