动态引导工具提示不会在手动触发时显示

Dynamic Bootstrap tooltip won't show on manual triggering

本文关键字:显示 工具提示 动态      更新时间:2023-09-26

似乎不会使用以下方法触发带有工具提示的动态创建的元素: $(this).tooltip('show');

我做错了什么?

在线复制

<div class="not-editable">
    <span>Click here</span>
</div>

.JS:

//dynamic tooltip
$('body').tooltip({
    selector: '.not-editable .to-edit',
    placement: 'bottom',
    trigger: 'manual',
    title: 'Actual times cannot be given as the trip is not confirmed',
    template: '<div class="tooltip error-tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
});
//dynamic added element...
setTimeout(function(){
    $('.not-editable').find('span').addClass('to-edit');
}, 1000);
//Trying to trigger the tooltip
$(document).on('click', '.to-edit', function(){
    console.log("showing...");
    $(this).tooltip('show');
});

实际更改

trigger: 'manual',

trigger: 'click | hover',

(与删除它一样多)也可以像:

https://jsfiddle.net/kj9sxnrc/4/

在引导工具提示文档中,它说

如何触发工具提示 - 单击 | 悬停 | 焦点 | 手动。您可以传递多个触发器;用空格分隔它们。 manual不能与任何其他触发器结合使用。