Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joemeador/8907610 to your computer and use it in GitHub Desktop.
Save joemeador/8907610 to your computer and use it in GitHub Desktop.
jQuery function to toggle Magento layered navigation attributes. Change .slice(1) to how many lists you want displayed by default.
jQuery(document).ready(function(){
// Adds open and close option for sidebar filters
jQuery('#narrow-by-list > dt:first').addClass('expanded');
jQuery('dl#narrow-by-list > dd').slice(1).hide();
jQuery('dl#narrow-by-list > dt a').click(function(){
jQuery(this).parent().next().slideToggle('slow');
jQuery(this).parent().toggleClass('expanded');
return false;
});
});
@simbus82
Copy link

for me is not working. Magento 1.9.2.3 + Extension SEO layered navigation
It works with:

jQuery(document).ready(function(){
        // Adds open and close option for sidebar filters
            jQuery('dl#narrow-by-list > dt:first').addClass('expanded');
            jQuery('dl#narrow-by-list > dd').slice(1).hide();
            jQuery('dl#narrow-by-list > dt').click(function(){
                jQuery(this).next().slideToggle('slow');
                jQuery(this).toggleClass('expanded');
                return false;
            });
        });

@vijayrami
Copy link

vijayrami commented Jul 17, 2016

`<script>

var $j= jQuery.noConflict();// no conflict method

$j (document).ready(function(){

$j("#narrow-by-list > dt").click(function(){

if(false == $j(this).next().is(':visible')) {

$j('#narrow-by-list dd').slideUp(300);

}
$j(this).next().slideToggle(300);

});

$j('#narrow-by-list dd').hide();

$j('#narrow-by-list dd:eq(0)').show();

});

</script>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment