Twitter Bootstrap Pills with Rails 3.2.2 [英] Twitter Bootstrap Pills with Rails 3.2.2

查看:42
本文介绍了Twitter Bootstrap Pills with Rails 3.2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照基本的 railscast 在 Rails 应用程序中使用 Twitter Bootstrap.一切都很好,直到我不得不推送到 heroku,然后我在 pg gem 上遇到了一些问题,我不得不 rake assets:precompile 来推送它.终于解决了.

现在,我正在尝试在我的应用程序中使用药丸,我从文档中复制/粘贴并更改了 href 中的 url :)

<div class="row"><div class="span3"><p>Lorem Ipsum</p>

<div class="span9"><ul class="nav nav-pills"><li class="active"><a href="/">首页</a></li><li><a href="/products">产品</a></li><li><a href="/categories">Categories</a></li>

当我推送其中一个链接时,我被重定向到正确的 URL,但所选选项不会更改为 class="active".我不知道为什么...我以为是 javascript 但悬停属性工作正常...我的意思是,当鼠标悬停在一个选项(不同于活动)上时,它的样式会改变.

我尝试了 rake assets:clean,但没有进行任何更改

谢谢

解决方案

你实际上必须自己处理!

您的列表应该类似于

 <li class="<%= 'active' if params[:controller] == 'yourdefaultcontroller' %>"><a href="/">Home</a></li><li class="<%= 'active' if params[:controller] == 'products' %>"><a href="/products">Products</a></li><li class="<%= 'active' if params[:controller] == 'categories' %>"><a href="/categories">Categories</a></li>

您需要在每个请求中指定哪个选项卡是活动的.您可以依靠在 params 哈希中传递的控制器名称(如果需要,还可以执行操作)来完成此操作.

I followed the basic railscast for using Twitter Bootstrap in Rails application. Everything was great, until I had to push to heroku, then I had some problems with pg gem, and I had to rake assets:precompile to push it ok. Finally I solved.

Now, I'm trying to use pills in my application, I have copy/paste from documentation and changed the url in href :)

<div class="container">
  <div class="row">

    <div class="span3">
      <p> Lorem Ipsum</p>
    </div>

    <div class="span9">    
      <ul class="nav nav-pills">
        <li class="active"><a href="/">Home</a></li>
        <li><a href="/products">Products</a></li>
        <li><a href="/categories">Categories</a></li>
      </ul>
    </div>

  </div>
</div>

When I push one of the links, I'm redirected to the right url but the selected option doesn't change to class="active". I don't know why... I thought it was the javascript but hover property works ok... I mean, when the mouse is over an option (diferent from active) its style changes ok.

I tried rake assets:clean, but no change is made

Thanks

解决方案

You actually have to handle this by yourself!

Your list should look something like

    <li class="<%= 'active' if params[:controller] == 'yourdefaultcontroller' %>"><a href="/">Home</a></li>
    <li class="<%= 'active' if params[:controller] == 'products' %>"><a href="/products">Products</a></li>
    <li class="<%= 'active' if params[:controller] == 'categories' %>"><a href="/categories">Categories</a></li>

You need to specify in each request which tab is the active one. You can do this by relying on the name of the controller (and action if need be) that is passed in the params hash.

这篇关于Twitter Bootstrap Pills with Rails 3.2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆