How to close layered navigation accordion on side click?
-
14-03-2021 - |
Question
If anyone can help me with how to close active accordion of layered navigation if clicked outside the layered navigation block?
<div class="filter-options" id="narrow-by-list" data-role="content" data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": false, "multipleCollapsible": false}}'>
this is the default accordion which is collapsible.
No correct solution
OTHER TIPS
Got the solution. Create a new js file and include it or edit any theme js file. Add below code.
/*Close Layered Navigation on side click*/
$(document).click(function(e) {
if (!$( "#narrow-by-list" ).is(e.target) && !$( "#narrow-by-list" ).has(e.target).length) {
$(".filter-options-item").collapsible("deactivate");
}
});
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange