数据表和引导工具提示 [英] Datatables and bootstrap tooltips

查看:73
本文介绍了数据表和引导工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Datatables添加到我的Rails应用程序中.我大部分时间都在使用它,但是我陷入了CSS/jQuery问题.我有一个行单元格定义如下:

I am adding Datatables to my Rails app. I have it working for the most part but I am stuck on a CSS / jQuery issue. I have a row cell defined as follows:

content_tag(:abbr, "#{record.od} mm", data: { container: 'body', toggle: 'tooltip', placement: 'bottom', html: 'true' }, title: 'test' )

呈现:

<abbr data-container="body" data-toggle="tooltip" data-placement="bottom" data-html="true" title="test">88.9 mm</abbr>

在非数据表中,引导工具提示工作正常,但在数据表上失败.根据经验,我认为这是因为数据表是在主体完成后呈现的.等等.

In a non-datatable table the bootstrap tooltip works fine but fails on the datatable. From experience I gather it's because the datatable is rendered after the body completes etc.

经过一番挖掘,我尝试了以下方法:

After some digging I tried this:

$ ->
  $('#table').dataTable
    ajax: 
      url: myurl
    processing: true
    serverSide: false
    responsive: true
    'fnCreatedCell': (nTd, sData, oData, iRow, iCol) ->
      $(nTd "abbr").tooltip()

这几乎行得通...几乎是因为我得到了一个工具提示,但是我猜想它是一个数据表工具提示而不是引导程序工具提示:

This almost works... almost because I get a tooltip but I am guessing it's a datatable tooltip vs the bootstrap tooltip:

忘记工具提示的内容-格式等问题.非引导工具提示也需要更长的时间才能淡入.

Forget the tooltip content - the formatting etc. is the issue. The non-bootstrap tooltip also takes way longer to fade in.

这里可能有简单的解决方法吗?

Is there perhaps an easy fix here?

谢谢

推荐答案

如注释中所述,您可以使用

As mentioned in the comments, you can use the selector option:

$('body').tooltip({selector: '[data-toggle="tooltip"]'});

这也适用于弹出窗口.

这篇关于数据表和引导工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆