문제

This seems like it would be a common case, but I cannot find any information on it. Perhaps it's something I'm just missing.

All tooltips are working as expected. However, we load some content dynamically, so it gets injected after the tooltip method is called.

What is the best way to get tooltips applied to new content which is injected after pageload?

UPDATE To be clear, I am not looking for how to inject dynamic content into a tooltip. I am looking for how to get the tooltip plugin to notice new content injected into the page.

Thanks

도움이 되었습니까?

해결책

I would do like this: Make your tooltip-options reusable like this:

var options = { content: "Awesome title!", ... }

Then make your first-tooltip-init on page load:

$('.someclass').tooltip(options);

After adding some new elements dynamically do like this:

$(dynamicallyaddedcontent).tooltip(options);

다른 팁

The jquery tooltip is a simple div, and as such you can inject content the same way you do with normal divs, using methods like JQuery's append. Best explained here.

EDIT: To match your edit I suppose you can find your answer here. Look at the second answer (the one with the more upvotes, not the accepted solution since it's deprecated)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top