【问题标题】:Error: Uncaught TypeError: Cannot read property 'Constructor' of undefined bootstrap-popover.js错误:未捕获的类型错误:无法读取未定义 bootstrap-popover.js 的属性“构造函数”
【发布时间】:2012-12-16 18:55:04
【问题描述】:

我想在我的 Rails 项目中手动使用 twitter 引导程序。
但是我遇到了这个错误,并且引导的某些功能不起作用。

如果您能帮助我,我将不胜感激。谢谢。

控制台错误

未捕获的类型错误:无法读取未定义 bootstrap-popover.js:38 的属性“构造函数”
(匿名函数)bootstrap-popover.js:38
(匿名函数)bootstrap-popover.js:115

app/view/app/index.html.erb

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<%= stylesheet_link_tag    "bootstrap" %>
<%= stylesheet_link_tag    "bootstrap-responsive" %>

<%= javascript_include_tag "jquery" %>
<%= javascript_include_tag "bootstrap" %>
<%= javascript_include_tag "bootstrap-transition" %>
<%= javascript_include_tag "bootstrap-alert" %>
<%= javascript_include_tag "bootstrap-modal" %>
<%= javascript_include_tag "bootstrap-dropdown" %>
<%= javascript_include_tag "bootstrap-scrollspy" %>
<%= javascript_include_tag "bootstrap-tab" %>
<%= javascript_include_tag "bootstrap-tooltip" %>
<%= javascript_include_tag "bootstrap-popover" %>
<%= javascript_include_tag "bootstrap-button" %>
<%= javascript_include_tag "bootstrap-collapse" %>
<%= javascript_include_tag "bootstrap-carousel" %>
<%= javascript_include_tag "bootstrap-typeahead" %>

<!-- as example, which doesn't work, somehow  -->
<i class="icon-search icon-home"></i>

我相信所有必要的 js 和 css 文件都在里面

  • ./app/assets/images
  • ./app/assets/javascripts
  • ./app/assets/stylesheets

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap ruby-on-rails-3.2


    【解决方案1】:

    如果您想在 Rails >3 中添加资产文件(如 .js.css 或图像),则应使用清单文件:application.js、application.css。复制目录中的源代码后,您应该进行如下声明:

    application.js :
    
    //= require jquery
    //= require jquery_ujs
    //= require bootstrap
    //= require bootstrap-responcive
    //= require tree .
    

    在 application.css 中:

    *= require_self
    *= require bootstrap
    *= require_tree .
    

    在视图中包含 ` 会变得毫无用处。

    【讨论】:

    • 我很乐意提供帮助。祝你好运。
    • 弄清楚它为什么起作用;通过“需要树”。在其他人之后,您确保以正确的顺序包含您的引导文件。将其留给文件名会以错误的顺序加载一些引导文件,例如工具提示之前的弹出窗口。
    猜你喜欢
    • 2014-01-03
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-26
    • 2021-12-22
    • 2015-01-06
    相关资源
    最近更新 更多