Manwal
Manwal

Reputation: 23816

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

Upvotes: 1

Views: 2574

Answers (2)

Manwal
Manwal

Reputation: 23816

I got this working by adding return

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

Upvotes: 3

Ferret
Ferret

Reputation: 1440

Wouldn't this do what you want too:

$('.tooltip')
    .tooltipster({
        theme: 'tooltipster-shadow',
        content: test()
    });

function test() {
    return $('<span><strong>See</strong> this is the new content.</span>');
}

Upvotes: 0

Related Questions