Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Updating Content

Is it possible to update the content of a tool tip on the fly? I.e. when someone hovers over an icon, we want the tool tip to say "Add To Favorites", once they click the icon, we would like the copy to read "Remove from Favorites".

I have it working as follows:

// this is a favorite so clicking will remove from favorites and adjust the copy + classname
$("").click(funtion() {
// run ajax to add to remove from favorites
Tipped.create($(this),'add to favorites');

// this is not a favorite so clicking will add to favorites and adjust the copy + classname
$("").click(funtion() {
// run ajax to add to favorites
Tipped.create($(this),'remove from favorites');

Ideally, we'd like to just update the copy and keep the tool tip open as the user clicks on the icon.


  • edited August 2015
    Tipped doesn't have an update method, you could show the tooltip with the API if it was open before removing and recreating it:
    $("").click(funtion() {
    var wasVisible = Tipped.visible(this);

    Tipped.create(this, 'add to favorites');

    if (wasVisible);

    By using an inline tooltip you could update it and call Tipped.refresh():
    <span id="favorite">click</span>
    <div id='favorite-tooltip' style='display:none'>add to favorites</div>

    <script type='text/javascript'>
    $(document).ready(function() {
    Tipped.create('#favorite', { inline: 'favorite-tooltip' });

    $('#favorite').click(function() {
    var makeFavorite = !$(this).hasClass('is-favorite'),
    tooltip = $('#favorite-tooltip');

    tooltip.html((makeFavorite ? 'remove from' : 'add to') + ' favorites');

    $(this)[(makeFavorite ? 'add' : 'remove') + 'Class']('is-favorite');
    Hope that helps.
  • That's great - thanks for the update! I'll be able to use this as a work around.
Sign In or Register to comment.