Bootstrap data-trigger ="focus"不起作用

Pet*_*ete 3 twitter-bootstrap

我在一个图标上定义了一个Bootstrap popover,如果我没有data-trigger ="focus"作为其定义的一部分,它可以正常工作.当我包含它时,单击图标时不会显示弹出窗口.这是没有数据触发器的代码.

<a data-toggle="popover" data-placement="left" data-title="Membership history for Fred Smith" data-html="true" data-content="<table><thead><tr><th class='col-md-2 text-left'>Renewed</th><th>Expiration</th><th>Type</th></tr></thead><tbody><tr><td>12/09/2016</td><td>12/31/2017</td><td>1-Year Individual</td></tr></tbody></table>"><span class="glyphicon glyphicon-info-sign" style="color:grey;"></span></a>
Run Code Online (Sandbox Code Playgroud)

而代码包括数据触发器:

<a data-toggle="popover" data-placement="left" data-trigger="focus" data-title="Membership history for Fred Smith" data-html="true" data-content="<table><thead><tr><th class='col-md-2 text-left'>Renewed</th><th>Expiration</th><th>Type</th></tr></thead><tbody><tr><td>12/09/2016</td><td>12/31/2017</td><td>1-Year Individual</td></tr></tbody></table>"><span class="glyphicon glyphicon-info-sign" style="color:grey;"></span></a>
Run Code Online (Sandbox Code Playgroud)

我还应该提到图标在表格单元格内.

有任何想法吗?

neo*_*yte 22

data-trigger="focus"在bootstrap popover上使用属性,您需要使用tabindex="0".像这样 - (编辑将tab-index更改为tabindex)

<a tabindex="0" data-toggle="popover" data-placement="left" data-trigger="focus" data-title="Membership history for Fred Smith" data-html="true" data-content="<table><thead><tr><th class='col-md-2 text-left'>Renewed</th><th>Expiration</th><th>Type</th></tr></thead><tbody><tr><td>12/09/2016</td><td>12/31/2017</td><td>1-Year Individual</td></tr></tbody></table>"><span class="glyphicon glyphicon-info-sign" style="color:grey;"></span></a>
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!

  • 我确实找到了关于此的文档,谢谢.我现在有它工作,它应该是tabindex,而不是tab-index.编辑了您的示例代码以显示该代码并将其标记为正确答案.跟进 - 看来我的编辑显示校正必须经过同行评审,以便最终可能会或可能不会显示. (3认同)

小智 5

" data-trigger="focus"不起作用,发生在您在锚点或跨度中使用 popover 时。 (当您使用 popover for button 时,data-trigger="focus" 正常工作)。

因此,在这种情况下,您必须为锚标记或跨度标记添加tabindex="-1"tabindex="0"

  • tabindex="0" 出现一个边界
  • tabindex="-1" 出现没有边框

例如。 <a data-toggle="popover" tabindex="-1" data-trigger="focus"> Click here</a>