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

时间:2016-03-21 18:16:49

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

似乎使用工具提示动态创建的元素不会使用:$(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');
});

1 个答案:

答案 0 :(得分:0)

实际上正在改变

trigger: 'manual',

trigger: 'click | hover',

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

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

Bootstrap Tooltips Docs它说

  

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