简体   繁体   English

将Jquery UI工具提示应用于延迟内容的正确方法?

[英]Proper manner for applying Jquery UI tooltip to deferred content?

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: 然后使您的first-tooltip-init加载页面:

$('.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 . jQuery工具提示是一个简单的div,因此,您可以像使用普通div一样使用JQuery的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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM