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
Similar problem, I just check if the element is visible:
$("#myDiv").is(":visible") ? $("#myDiv").collapse('hide') : /*do nothing*/;