Search code examples
jquerytooltip

Change content of tooltipster on initialize


I have too many link on a page having tooltip, I want to set content of every link's tooltip on initialize time.

Here is following code i am using:

$('.help_tooltip').tooltipster({
    theme: 'tooltipster-shadow',
    functionInit: function(origin, content) {
        origin.tooltipster('content','testing content');// here i want to call my custom function 
    }
});

but when i run this code this giving me error:

Uncaught Error: You called Tooltipster's "content" method on an uninitialized element

I found in Documentation http://iamceege.github.io/tooltipster/#functionInitExample we can change text of tooltip on initialization.

Here is demo http://jsfiddle.net/w481vx1g/

Gitub Issue https://github.com/iamceege/tooltipster/issues/317


Solution

  • I got this working by adding return

    $('.help_tooltip').tooltipster({
        theme: 'tooltipster-shadow',
        functionInit: function(origin, content) {
           return "new content';
        }
    });