我有一堆可以通过单击图标单独折叠/展开的项目。我需要再修改一下我的代码。我需要在顶部添加另一个图标。当您单击它时,您可以一次展开/折叠以下所有项目。有人可以帮我做那部分吗?
这是我的javascript代码
$(document).on('show hide', '#programs-accordion', function(e) {
$(e.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-plus icon-minus');
});
这是我的haml代码
#programs-accordion.accordion
- @patient_summary.programs.each_with_index do |program, index|
.accordion-group
.accordion-heading
.accordion-toggle.group-accordion-toggle
%a{ href: "#collapse-#{index}", data: { parent: '#programs-accordion', toggle: 'collapse' }}
%i.icon-plus
%a= program.name
.accordion-body{id: "collapse-#{index}", class: (@office.to_i == office.id) ? "" : "collapse" }
.accordion-inner
- office.positions.each_with_index do |position, index|
#measures-accordion.accordion
.accordion-group
.accordion-heading
.row-fluid
.span2{class: "offices-#{position.status}"}= position.status
.span1= position.results.first.value
.span2= position.results.first.value_date_time.blank? ? '' : Date.parse(position.results.first.value_date_time)
.span5= position.name
编辑:下面的JS小提琴链接