【问题标题】:NgbTooltip doesn't trgigger on <td> elementNgbTooltip 不会在 <td> 元素上触发
【发布时间】:2020-03-10 18:43:42
【问题描述】:

我正在尝试将 ngbTooltip 放在 &lt;table&gt; 元素上
我已经在&lt;th&gt; 上遇到了问题,通过使用container 解决了这个问题,感谢post
问题出现在&lt;td&gt; 元素上,该元素不显示任何工具提示,我在文档后找不到任何答案。

<tbody>
<ng-container *ngFor="let line of aggreg | sortByElement:filterField:ascending; let idx = index">
  <tr *ngIf="showLine(line)">
    <!-- tds without tooltips here -->
  </tr>
  <ng-container *ngIf="detailsSelected === idx && showLine(line)">
    <tr *ngFor="let color of getColors(line) | sortByElement:'count':'false'" class="subline">
      <!-- tds without tooltips here -->

      <!-- Tooltip doesn't display when condition is true -->
      <td ngbTooltip="foo" placement="left" *ngIf="conditionHere" class="..." (click)="redirect(line)">
        <i class="fas fa-times"></i>
      </td>
      <!-- Tooltip doesn't display when condition is true -->
      <td ngbTooltip="bar" placement="left" *ngIf="otherConditionHere" class="..." (click)="redirect(line)">
        <i class="fas fa-check"></i>
      </td>
      <!-- Tooltip doesn't display when condition is true -->
      <td ngbTooltip="baz" placement="left" *ngIf="anotherConditionHere" class="..." (click)="redirect(line)">
        <i class="fas fa-camera"></i>
      </td>
    </tr>
  </ng-container>
</ng-container>
</tbody> 

同样添加container="body" 并不能解决&lt;td&gt;

【问题讨论】:

    标签: html angular bootstrap-4 ng-bootstrap


    【解决方案1】:

    您是否尝试过手动触发事件以显示工具提示?如果工具提示代码出现在某处,请尝试触发它并检查您的 html,这可能是一个 css 问题,可以通过重载某些属性来进行调整。

    【讨论】:

    • &lt;td&gt; 切换到&lt;div&gt; 确实会显示我的工具提示,但这是一个丑陋的实现
    • 看起来他们的联播没有绑定到&lt;td&gt; elements tbh
    • 你可以在 td 中创建一个 div,而不是代替 td ?
    • @Random 这也是我尝试过的(它可以在另一个页面上使用 #MyToolTip 的间接调用)但它也没有显示,两种可能性,CSS 问题 (将无法上传全局css,因为它是出于专业目的)或直接使用 ngbTooltip(不绑定#MyTooltip
    猜你喜欢
    • 2014-11-11
    • 2022-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多