如何覆盖 twitter bootstrap 工具提示? [英] How to overwrite twitter bootstrap tooltip?

查看:44
本文介绍了如何覆盖 twitter bootstrap 工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Twitter Bootstrap 包中的工具提示在页面上显示项目信息.有时信息会更改,需要在工具提示中更新.我只是尝试用新标题重新初始化工具提示:

I'm using tooltips from Twitter Bootstrap package to show items information on the page. Sometimes information is changed, and needs to be updated in the tooltip. I tried simply to reinitialize tooltip with new title:

$('#selector').tooltip({ title: 'new text'});

然而,工具提示的标题不会随着新文本而改变.它保持与最初设置的相同.任何想法为什么,是否有任何解决方法?谢谢!

However tooltip's title doesn't get changed with the new text. It remains the same as it was set initially. Any ideas why, and is there any work around? Thanks!

推荐答案

一旦在一个元素上初始化了工具提示对象,就不能覆盖它.但是你可以删除它然后再做一次.

You can't override the tooltip object once you have initialized it on one element. But you can delete it and do it again.

尝试删除,然后使用所有选项(如果有)重新初始化工具提示.

Try deleting and then reinitialize the tooltip with all your options (if you had any).

$('#selector').data('bs.tooltip',false)          // Delete the tooltip
              .tooltip({ title: 'new text'});

可能需要删除监听器,但它的工作原理是这样的.

There may be a need to remove the listeners, but it works like that.

在 TWBS v3 之前,您不需要 bs 命名空间给出:data('tooltip')

Before TWBS v3 you would not need the bs namespace giving : data('tooltip')

这篇关于如何覆盖 twitter bootstrap 工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆