javascript - 如何在 Rails 中安装 jschr 的 bootstrap-modal

标签 javascript css ruby-on-rails twitter-bootstrap

我正在尝试安装在这里找到的 jschr 的 bootstrap-modal:https://github.com/jschr/bootstrap-modal在我的 Rails 元素中使用。

github页面的说明表明:

  • 在主 Bootstrap css 文件之后包含 css/bootstrap-modal.css。
  • 在主 Bootstrap js 文件之后包含 js/bootstrap-modalmanager.js 和 js/bootstrap-modal.js。

这是什么意思?我认为 bootstrap 是通过包含在 gemfile 中并运行 bundle update/install 安装在 rails 中的。

最佳答案

如何安装:

Vicente Reig created a Ruby Gem for you to use!

按照他的安装说明将 gem 添加到您的 gemfile,然后安装 gem。这会将您需要的文件添加到您的 gem 目录中。

如何初始化:

您需要添加两个require 语句:

application.js 文件中的第一个: 前几行将用 // 注释掉,这是您添加 .js 调用的地方。

//= require bootstrap-modal
//= require bootstrap-modalmanager

在你的 application.css 文件中做同样的事情:

//= require bootstrap <--(this should already be there.)
//= require bootstrap-modal

如果您的 application.css 文件没有 require bootstrap 行,那么它可能有:

@import "bootstrap";

如果是这样,添加:

@import "bootstrap";
@import "bootstrap-modal";

那样的话,bootstrap-modal 加载第二。

关于javascript - 如何在 Rails 中安装 jschr 的 bootstrap-modal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25026659/

相关文章:

javascript - 在 jquery 中删除一个 div 不起作用

JavaScript/jQuery - offsetLeft 和 offsetTop

html - 带有非静态网页帮助的粘性页脚

HTML anchor 标记

ruby-on-rails - Rails 4与您管

ruby-on-rails - 部署 Rails 应用程序

ruby-on-rails - Rails 3 - 在更新之前使用参数检查对象是否有效

javascript - 在 Javascript 中,在哪些情况下应该使用 `==` 而不是 `localeCompare`,反之亦然?

javascript - 在 Angular2 中,检测组件滚动的最简单方法是什么

jquery - 使用 jQuery 使连续的第一张图片消失