禁用/销毁后重新应用 Twitter 引导工具提示



我有一个简单的问题。我从表中的选定项目显示数据,因此它经常更改。我正在使用它来检查溢出:

if (event.target.offsetWidth < event.target.scrollWidth) {
            if ($(event.target).attr('tooltip')) {
                $(event.target).tooltip('enable');
            } else {
                $(event.target).tooltip({
                    title: $(event.target).text(),
                    placement: 'bottom',
                    animation: false
                });
                $timeout(function () {
                    $(event.target).tooltip('show');
                });
            }
        } else {
            $(event.target).tooltip('disable');
        }

这有效,但我无法在禁用后显示工具提示。我尝试销毁代替禁用(未出现在文档中)并在销毁后添加整个工具提示。无济于事。如何替换已销毁/禁用的工具提示?

如果我动态禁用并重新启用工具提示,我会先清除'bs.tooltip',然后再调用节目。 像这样:

$('#element').data('bs.tooltip', null);
$('#element').tooltip({ placement: 'bottom' });
$('#element').tooltip('show');

并禁用:

$('#element').tooltip('disable');

试试这个,这对你来说会很好用

$('#element').tooltip({
    title: 'My first tooltip'
}); // Add the tooltip
$('#element').tooltip('show'); // Show the tooltip
$('#element').tooltip({
    title: 'I want to change this tooltip'
}); // Try to change the tooltip
$('#element').tooltip('show'); // The tooltip will still say 'My first tooltip'
/****************************/
$('#element').data('tooltip', false); // Remove the previous tooltip
$('#element').tooltip({
    title: 'This is the new tooltip'
}); // Try to change the tooltip
$('#element').tooltip('show'); // The tooltip should say 'This is the new tooltip'

最新更新