【问题标题】:Dynamic Bootstrap tooltip won't show on manual triggering动态引导工具提示不会在手动触发时显示
【发布时间】:2016-07-08 09:56:13
【问题描述】:

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

我做错了什么?

Reproduction online

<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');
});

【问题讨论】:

    标签: javascript css twitter-bootstrap twitter-bootstrap-3


    【解决方案1】:

    实际变化

    trigger: 'manual',
    

    trigger: 'click | hover',
    

    (就像删除它一样)也可以像在中一样工作:

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

    Bootstrap Tooltips Docs 上面写着

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    • 1970-01-01
    相关资源
    最近更新 更多