Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 引导工具提示不适用于动态生成的行_Jquery_Html_Twitter Bootstrap - Fatal编程技术网

Jquery 引导工具提示不适用于动态生成的行

Jquery 引导工具提示不适用于动态生成的行,jquery,html,twitter-bootstrap,Jquery,Html,Twitter Bootstrap,我有一个表,其中的行是动态生成的。我必须向所有动态生成的行中的一个单元格添加工具提示。工具提示适用于但不适用于 这是我的桌子 <table> <thead> <tr><th id="table-head" data-toggle="popover" data-trigger="" data-content="Sample Tootlip">Table Head</th></tr> </thead>

我有一个表,其中的行是动态生成的。我必须向所有动态生成的行中的一个单元格添加工具提示。工具提示适用于但不适用于

这是我的桌子

<table>
  <thead>
    <tr><th id="table-head" data-toggle="popover" data-trigger="" data-content="Sample Tootlip">Table Head</th></tr>
  </thead>
<tbody>
<tr data-ng-repeat="item in Samplelist">
<td class="tableContent" data-toggle="popover" data-trigger="" data-content="Content Tootlip">{{item.value}}</td>
</tr>
</tbody>
</table>
工具提示显示在中,但不显示在中
是因为它是动态的吗?如何解决它?

您的假设是正确的,即问题是因为行是动态创建的。因此,当

.popover({...})
函数被调用

解决方案: 你需要做的是打电话给

.popover()
当您将鼠标悬停在元素上时,函数

$('body').on('mouseenter', '.tableContent', function () {
    if ($(this).attr('data-toggle') != 'popover')
    {
        $(this).popover({
            container: 'body',
            placement: 'left',
            trigger: 'hover'
        }).popover('show');
    }
});
解释 当鼠标悬停在您的元素上时,将检查是否已添加数据切换,如果尚未添加。popover函数被称为添加数据切换,并且调用popover“show”在第一次悬停时实际显示项目

在此之后,popover功能应在悬停状态下正常工作


希望能有帮助。愉快的编码。

您的假设是正确的,即问题是因为行是动态创建的。因此,当

.popover({...})
函数被调用

解决方案: 你需要做的是打电话给

.popover()
当您将鼠标悬停在元素上时,函数

$('body').on('mouseenter', '.tableContent', function () {
    if ($(this).attr('data-toggle') != 'popover')
    {
        $(this).popover({
            container: 'body',
            placement: 'left',
            trigger: 'hover'
        }).popover('show');
    }
});
解释 当鼠标悬停在您的元素上时,将检查是否已添加数据切换,如果尚未添加。popover函数被称为添加数据切换,并且调用popover“show”在第一次悬停时实际显示项目

在此之后,popover功能应在悬停状态下正常工作


希望能有帮助。快乐的编码。

如果$this.attr'data-toggle'=='popover'它应该是==不=如果$this.attr'data-toggle'='popover',它应该是==不=