如何在我的Rails应用程序中使用Bootstrap的进度条?

时间:2013-06-28 17:40:43

标签: ruby-on-rails twitter-bootstrap progress-bar

我正在寻找一个在Rails App中使用twitter bootstrap的progres bar的例子。

我是网络开发人员的新手,我不知道这样做。

我可以使用其他进度条,但在Rails APp ...

3 个答案:

答案 0 :(得分:0)

尝试使用为您的资产管道添加引导程序的gem,这将使您的生活更轻松:https://github.com/thomas-mcdonald/bootstrap-sass

一旦你添加了宝石,就把JS和Css导入资产管道,如下所示:

创建一个css.scss文件。在您的资产> stylesheets文件夹中 boot.css.scss:

$navbarBackground: #000;
$navbarText: #fff;
$navbarLinkColor: #888;
$navbarBrandColor: #FFF;

@import "bootstrap";
@import "bootstrap-responsive";

的application.js:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require_tree .

在您的管道中的宝石重新启动应用程序后,您可以像这样添加进度条:

<div class="span8 progress progress-striped active"><div id="bar" class="bar" style="width: 100%;"></div></div>

答案 1 :(得分:0)

存在宝石; - )

https://github.com/yrgoldteeth/css3-progress-bar-rails

要为进度条设置动画,您必须使用javaScript

答案 2 :(得分:0)

我在index.html.erb中包含了这个。它将使用Twitter Bootstrap根据数据库字段中的值设置进度条,并显示%progress

<tbody>
    <% @active_xfers.each do |active_xfer| %>
      <tr>
        <td><%= active_xfer.name %></td>
        <td><%= active_xfer.status %></td>


<td><div class="progress">
  <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="<%= active_xfer.progress %>" aria-valuemin="0" aria-valuemax="100" style="width: <%= active_xfer.progress %>;">
    <%= active_xfer.progress %>
  </div>
</div></td>

        <td><%= active_xfer.started %></td>
        <td><%= active_xfer.finished %></td>

      </tr>
    <% end %>
  </tbody>