views:

105

answers:

2

I'm using this jQuery Tooltip plugin: http://docs.jquery.com/Plugins/Tooltip

I create tooltips for all links when the document is ready, like that:

$(function() {
    $('a').tooltip();
}

But when I add some links to the document later, the plugin wouldn't display jQuery tooltip on them.

I supposed that when I call $('a').tooltip(); again after I created those new links, jQuery will create tooltips for them too. It won't, it'll even ruin all jQuery tooltips I have.

How can I create tooltips on newly created links? Is it possible to release the current tooltips and call it again on all links or something like that? Or can I create the tooltips for links that haven't been created yet?

A: 

You could use Livequery to do this:

$("a").liveQuery(function(){
  $(this).tooltip();
});

As for not adding tooltips to links that have already been processed (I don't think livequery will do that anyway), (but if for some reason it did) you could add a class "tt-processed" to links after they've been modified, and from then on out only select for links that don't have that class.

Jonathan Sampson
Thanks, this is exactly what I wanted. btw. It's livequery (with lowercased Q).
tomp
Sorry, I'm too accustomed to saying "jQuery," the big-Q comes natural ;)
Jonathan Sampson
liveQuery....too much overhead
redsquare
A: 

You could try something like

$(e).append("<a>some link</a>").tooltip();
stefita