ruby on rails -折叠开关不工作与Twitter引导手风琴



我试图让我的侧边栏的4个链接,包括底部链接作为一个可折叠的链接。也就是说,当底部链接处于活动状态时,它下面应该有两个额外的"子链接"。当用户点击回到前3个链接中的任何一个时,底部(第4个)链接应该折叠起来。显示上述两个子链接。

任何关于如何得到这个工作的帮助都是非常感谢的。

我的代码如下:
<li><a href="#">Current State</a></li>
<li><a href="#">Issues</a></li>
<li><a href="#">Requests</a></li>
<li class="panel-group <%= 'active' if current_page?project_settings_path(project) %>" id="accordion">
  <%= link_to 'Settings', project_settings_path(project) %>
  <div id="demo" class="collapse in">
   <%= link_to 'general', some_path_a(project) %> # this page should be active after the user clicks on the 'Settings' list item link above
   <%= link_to 'invites', some_path_b(project) %>
  </div>
  <script>
   $("#demo").collapse({"toggle": true, 'parent': '.panel-group'});
  </script>
</li>

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
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .

好的,我去掉了bootstrap折叠的东西&javascript和刚刚在第4个列表项上做了一个基本的rails'if'语句(在我上面提到的'demo'div上)…看起来是这样的:

<% if current_page?(project_settings_path(project)) || current_page?(project_invites_path(project)) %> 
  <div id="demo" class="collapse in pull-right">
   <ul>
     <li style="margin: 10px 0px;">
       <%= link_to 'General Settings', project_settings_path(project) %>
     </li>
     <li>
      <%= link_to 'Add Collaborators', project_invites_path(project) %>
     </li>
    </ul>
   </div>
<% end %>

我不确定这是不是最好的方法,但它确实是需要的。

最新更新