bootstrap下拉菜单不会下拉

时间:2014-05-08 20:25:58

标签: html css twitter-bootstrap

这是我的haml导航面板,带有bootstrap。这是另一位开发人员留下的东西。我的html / css / design技能很少。

.navbar.navbar-static-top
  .navbar-inner
    .container
      %a.btn.btn-navbar(data-target=".nav-collapse" data-toggle="collapse")
        %span.icon-bar
      %a.brand{ href: 'http://www.url.com' }
        =image_tag 'amazons3url'
      .nav-collapse.collapse
        %ul.nav.pull-left
          %li.divider-vertical
          -if student_signed_in?
            %li.dropdown
              %a.dropdown-toggle(data-toggle='dropdown' href='#')
                =t('.account')
                %b.caret
              %ul.dropdown
                %li
                  =link_to(t('.register_event'), new_event_path)
                %li
                  =link_to(t('.events'), events_path)
                %li
                  =link_to(t('.sign_out'), destroy_student_session_path,
                           method: :delete)
          -else
            %li 
              =link_to(t('navigationbar.sponsors'), brands_path) 
            %li 
              =link_to(t('navigationbar.works'), page_path('how_it_works'))
            %li
              =link_to(t('navigationbar.about'), page_path('about'))
            %li
              =link_to(t('navigationbar.signup'),
                new_student_registration_path)
            %li.divider-vertical
            %li.divider-vertical
            %li
              =link_to(t('navigationbar.login'), new_student_session_path)
            %li.divider-vertical
              =link_to(t('navigationbar.event'), new_sponsorship_path)

          %li.divider-vertical
          %li.divider-vertical
          %li.dropdown
            %a.dropdown-toggle(data-toggle='dropdown' href='#')
              =t('navigationbar.language')
            %ul.dropdown-menu
              %li
                =link_to('繁體中文', locale: 'zh-HK')
              %li
                =link_to('简体中文', locale: 'zh-CN')
              %li
                =link_to('English', locale: 'en')

我遇到了这个部分的问题

      %li.dropdown
        %a.dropdown-toggle(data-toggle='dropdown' href='#')
          =t('navigationbar.language')
        %ul.dropdown-menu
          %li
            =link_to('繁體中文', locale: 'zh-HK')
          %li
            =link_to('简体中文', locale: 'zh-CN')
          %li
            =link_to('English', locale: 'en')

当我点击语言时,它将转到此

# instead of the links
如果我改变

,它会半工作
%ul.dropdown-menu  

%ul

链接将是子弹点,它真的很难看。我已经检查了bootstrap doc,我应该指定ul类的下拉菜单,所以我看不出是什么问题?

此下拉列表对我不起作用

 -if student_signed_in?
            %li.dropdown
              %a.dropdown-toggle(data-toggle='dropdown' href='#')
                =t('.account')
                %b.caret
              %ul.dropdown
                %li
                  =link_to(t('.register_event'), new_event_path)
                %li
                  =link_to(t('.events'), events_path)
                %li
                  =link_to(t('.sign_out'), destroy_student_session_path,
                           method: :delete)

1 个答案:

答案 0 :(得分:0)

检查您是否包含了显示下拉菜单所需的js插件,如果没有,当您点击它时只会在网址末尾添加#。

检查此http://getbootstrap.com/javascript/#dropdowns