I try to use the toggle function of the Bootstrap collapse plugin programmatically. I manage to toggle a div when I click on the link in accordion-heading but it works only once, that is to say I cannot click again to hide the div.
Here is my code :
<div id="accordion" class="accordion">
<div class="accordion-group">
<div class="accordion-heading">
<a id="program${bean.id}" data-parent="#accordion"
class="accordion-toggle">
...
</a>
</div>
<div id="collapse${bean.id}" class="accordion-body collapse">
<div class="accordion-inner">
...
</div>
</div>
</div>
And later in the JSP :
$.each($('#accordion a.accordion-toggle'), function(i, link){
$(link).on('click',
function(){
// ...
$('#collapse' + id_of_a_bean).collapse({
toggle : true,
parent : '#accordion'
});
// ...
}
)
});
Did I miss something?