Building on the Quick Start example, you can create a function to collapse all open panes in the accordion.
Note: In addition to creating our function, we also need to change the requireOpenedPane option, which is set to true by default, because it prevents all of the panes from collapsing.
Collapse Script |
Copy Code |
---|---|
<script type="text/javascript"> $(document).ready(function () { $("#accordion").wijaccordion({ header: "h2", expandDirection: "right", requireOpenedPane: false }); $("#collapseAll").click(function(){collapseAll();}); }); function collapseAll(){ var accordion = $("#accordion"); accordion.wijaccordion("activate", accordion.find(".wijmo-wijaccordion-header.ui-state-active")); } </script> |
Button Markup |
Copy Code |
---|---|
<button id = "collapseAll">Collapse All</button> |