默认情况下,在Data-toggle =“collapse”bootstrap下打开导航

时间:2015-05-17 17:38:06

标签: javascript jquery html twitter-bootstrap

我是bootstrap的新手。我正在使用data-toggle =“collapse”制作侧边栏手风琴导航,但它默认关闭导航。我该怎么办默认情况下打开导航,当我点击它时它就会关闭。

HTML

!function ($) {
    $(document).on("click","ul.nav li.parent > a > span.icon", function(){          
        $(this).find('em:first').toggleClass("glyphicon-minus");      
    }); 
    $(".sidebar span.icon").find('em:first').addClass("glyphicon-plus");
}(window.jQuery);

JS

def build_links(resource)
  YAML.load_file("config/admin_links.yml")[resource].collect do |link|
  active = (eval(link.last) == request.path) ? "active" : ""
  path = link.last.empty? ? "#" : eval(link.last)

  content_tag(:li, link_to(link.first, path), class: active)
end.join.html_safe

1 个答案:

答案 0 :(得分:0)

您需要将in类添加到ul。即:

<ul class="children in collapse" id="sub-item-3">