似乎使用工具提示动态创建的元素不会使用:$(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');
});
答案 0 :(得分:0)
实际上正在改变
trigger: 'manual',
到
trigger: 'click | hover',
(与删除它一样)也可以在:
https://jsfiddle.net/kj9sxnrc/4/
如何触发工具提示 - 点击|悬停|焦点|手册。你可以传递多个触发器;用空格隔开它们。
manual
不能与任何其他触发器结合使用。