【问题标题】:Twitter Bootstrap Popovers not workingTwitter Bootstrap Popovers 不工作
【发布时间】:2013-07-06 03:37:59
【问题描述】:

这是我的 HTML:

<div id="disclaimer">After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div>

JavaScript:

$('#disclaimer').popover({
  trigger: 'hover',
  html: true,
  placement: 'right',
  content: 'hello world'
});

当我将鼠标悬停在元素上时,没有任何反应.. 没有 JavaScript 错误或任何东西,不确定是什么问题

【问题讨论】:

    标签: twitter-bootstrap popover


    【解决方案1】:

    使用您的确切代码,我所要做的就是将它包装在一个函数调用中并将脚本放在 div 标签下面。如果您将 jQuery 放在 onload 函数中,它也可以正常工作。祝你好运。

    使用这个:

    <div id="disclaimer" >After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div>
    
    <script>
    $(function ()  
    {
      $('#disclaimer').popover(
      {
         trigger: 'hover',
         html: true,
         placement: 'right',
         content: 'hello world'
      });
    });
    </script>
    

    $(document).ready(function()
    {
      $('#disclaimer').popover(
      {
         trigger: 'hover',
         html: true,
         placement: 'right',
         content: 'hello world'
      });
    });
    

    【讨论】:

    • 我的包裹在$(document).ready 中,但仍然没有任何反应:(
    • 能不能放到script标签里的html里面?如果这仍然不起作用,您可能需要检查以确保您的 bootstrap.js 中包含工具提示
    • 我想通了...这是 ActiveAdmin JavaScript 与 twitter 引导程序冲突...感谢您的帮助!
    • 我同意,活跃的管理员导致了冲突。我通过将活动管理员移动到 vendor/javascripts 目录来解决它并且它有效
    【解决方案2】:

    我一直在寻找为什么我的弹出框在由于我的页面上发生的事件而被自动禁用后无法工作(一个复杂的应用程序,根据正在发生的状态启用/禁用的东西) ),关键是不要让它准备好文档,而是将它放在一个函数中,因为它在单击按钮时文档初始化后启用。

    【讨论】:

    • 您似乎无法克隆弹出框,这是我的问题。谢谢,这个提示让我尝试了不同的方法。如果我在克隆后应用弹出框,它可以工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    相关资源
    最近更新 更多