引导工具提示不't在与第一个数据表不同的页面中工作
Bootstrap tooltips don't work in page different from the first of datatables
我正在开发几个数据表,其中一些列的单元格具有引导工具提示。所以我用的是:
- Bootstrap框架
- 数据表
数据表分为几个页面。当文档准备好并加载表时,在数据表的第一页中,工具提示工作正常,但下一页的单元格没有工具提示!
我该如何解决这个问题?
解决方案
每次DataTables重新绘制表时,都需要使用drawCallback
来初始化工具提示。这是需要的,因为在显示第一个页面时,除了第一个页面之外的页面的TR
和TD
元素不存在于DOM中。
演示
$(document).ready(function() {
var table = $('#example').DataTable( {
ajax: 'https://api.myjson.com/bins/qgcu',
drawCallback: function(settings){
var api = this.api();
/* Add some tooltips for demonstration purposes */
$('td', api.table().container()).each(function () {
$(this).attr('title', $(this).text());
});
/* Apply the tooltips */
$('td', api.table().container()).tooltip({
container: 'body'
});
}
});
});
<link href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<table id="example" class="display">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Salary</th>
<th>Start Date</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Salary</th>
<th>Start Date</th>
</tr>
</tfoot>
</table>
链接
有关更多示例和详细信息,请参阅jQueryDataTables:Custom控件在第二页及之后不起作用。
相关文章:
- 数据表 + 列搜索 + 整体搜索协同工作 + 服务器端处理
- 数据表自动生成的序列号无法正常工作.对于每一页
- 数据表中的FixedHead没有'删除分页后无法工作
- 谷歌脚本-从网站论坛解析HTML-并将数据写入工作表
- JQuery 数据表列数据更新工作太慢
- 数据表正则表达式搜索无法按预期工作以实现完全匹配
- aa数据表中的排序无法正常工作
- 无法让数据表与 Django 生成的表一起工作
- 引导工具提示不't在与第一个数据表不同的页面中工作
- 使用jQuery来突出显示不工作的数据表行
- JQuery .on('click')不工作在数据表第二页或行过去11
- 数据表中所有页面总量不工作,只工作当前页面
- 数据表过滤&行高亮不能一起工作
- ajax.dataSrc的数据表不工作
- 在ajax后绘制的数据表上单击事件,该数据表不能从第二页工作
- 具有数据表搜索功能的Daterangepicker无法工作
- 适应谷歌表API Node.js快速开始与我自己的表工作,错误:错误:无法解析范围:类数据!
- 从数据表行打印工作表而不首先打开它
- 哪些文件需要的数据表工作的html页面>
- 模式窗口不能为分页数据表工作