我正在尝试让引导折叠功能与 Rails 中的循环一起使用。目前只有循环中的第一个项目有效,但是当第二个项目被点击时,它只会折叠第一个项目。下面是我的代码。使这种动态的最佳方法是什么?
<div class="accordion" id="accordion2">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
<h3><%= i.firstname %><%= i.lastname %></h3>
</a>
</div>
<div id="collapseOne" class="accordion-body collapse in">
<div class="accordion-inner">
<%= i.email %></br>
Payed: <%= i.payed? %></br>
Birthday: <%= i.dateofbirth %><br />
Address: <%= i.address %><br />
City: <%= i.city %><br />
Province: <%= i.province %><br />
Phone Number: <%= i.phonenumber %><br />
Service Provider: <%= i.serviceprovider %><br />
Gender: <%= i.gender %><br />
Languages: <%= i.languages %><br />
<h3>School Information</h3>
Highschool: <%= i.app.highschool %><br />
Address: <%= i.app.highschool_address %><br />
City: <%= i.app.highschool_city %><br />
Province: <%= i.app.highschool_province %><br />
Postal Code: <%= i.app.highschool_postalcode %><br />
<h4>Post Secondary Schools of Interest</h4>
<% i.app.postsecondaries.each do |ps| %>
Post Secondary Name: <%= ps.postsecondary %><br />
Address: <%= ps.postsecondary_address %><br />
City: <%= ps.postsecondary_city %><br />
Province: <%= ps.postsecondary_province %><br />
Postal Code: <%= ps.postsecondary_postalcode %><br />
Country: <%= ps.postsecondary_country %><br />
Program: <%= ps.postsecondary_program %><br />
Faculty: <%= ps.postsecondary_faculty %><br />
Status: <%= ps.postsecondary_status %><br />
<% end %>
</div>
<div class="span3 well">
<h3>Grades</h3>
<% i.app.grades.each do |grade| %>
<br />Course: <%= grade.course %><br />
Grade: <%= grade.course_grade %>
<% end %>
</div>
<div class="span3 well">
<h3>Extracurricular Activities</h3>
<% i.app.extra_activities.each do |e| %>
Activity: <%= e.activity %><br />
Position: <%= e.activity_position %><br />
Dates: <%= e.activity_dates %><br />
Times Per Week: <%= e.activity_timeperweek %><br />
Contact Name: <%= e.activity_contact %><br />
Contact Position: <%= e.activity_contact_position %><br />
Contact Phone Number: <%= e.activity_contact_phonenumber %><br />
Contact Email: <%= e.activity_contact_email %><br />
Description: <%= e.activity_description %>
<% end %>
<h3>Essay 1</h3>
Describe the situation: <%= i.app.describe_situation %></br>
</br>Explain the actions you took in response to the situation: <%= i.app.explain_action %></br>
</br>Identify the good that resulted once the situation was resolved: <%= i.app.resolved_situation %></br>
</br>What personal strength or skill did you use that was key in determining the outcome?: <%= i.app.personal_skill %></br>
<h3>Essay 2</h3>
Describe the situation: <%= i.app.describe_situation_two %></br>
</br>Explain the actions you took in response to the situation: <%= i.app.explain_action_two %></br>
</br>Identify the good that resulted once the situation was resolved: <%= i.app.resolved_situation_two %></br>
</br>What personal strength or skill did you use that was key in determining the outcome?: <%= i.app.personal_skill_two %></br>
<h3>Essay 3</h3>
Describe the situation: <%= i.app.describe_situation_three %></br>
</br>Explain the actions you took in response to the situation: <%= i.app.explain_action_three %></br>
</br>Identify the good that resulted once the situation was resolved: <%= i.app.resolved_situation_three %></br>
</br>What personal strength or skill did you use that was key in determining the outcome?: <%= i.app.personal_skill_three %></br>
</div>
</div>
</div>
</div>
<% end %>