在rails中实现bootstrap选项卡

时间:2014-06-02 16:29:03

标签: javascript jquery ruby-on-rails twitter-bootstrap jquery-ui-tabs

我正在尝试使用Rails4.1的Bootstrap选项卡。 这是我的haml代码:

.container-fluid
  .row-fluid
    .span8.well
      %ul.nav.nav-tabs
        %li.active
          %a{"data-target" => "#home", "data-toggle" => "tab", href: "#home", id: '#home_link'} Home
        %li
          %a{"data-target" => "#profile", "data-toggle" => "tab", href: "#profile", id: '#profile_link'} Profile
      .tab-content
        #home.tab-pane.active.fade.in home tab content
        #profile.tab-pane profile tab content

在我的application.js中我有

//= require bootstrap

第一次加载页面时,它会显示主页选项卡内容,但之后点击任何选项卡都不会显示任何内容。我不知道我缺少的地方。感谢

1 个答案:

答案 0 :(得分:1)

通过

自行解决
.container-fluid
  .row-fluid
    .span8.well
      %ul.nav.nav-tabs
        %li.active
          %a{"data-toggle" => "tab", href: "#home"} Home
        %li
          %a{"data-toggle" => "tab", href: "#profile"} Profile
        %li
          %a{"data-toggle" => "tab", href: "#messages"} Messages
        %li
          %a{"data-toggle" => "tab", href: "#settings"} Settings
      / Tab panes
      .tab-content
        #home.tab-pane.active 1
        #profile.tab-pane 2
        #messages.tab-pane 3
        #settings.tab-pane 4