Perrotekel Posted May 26, 2021 Share Posted May 26, 2021 Hi, I have a shop with many categories and I whould like hide "categories" not selecteds into product page ( backoffice ) I try modify document ready with 2 steps. 1.- Collapse all 2.- Click on parent from checkbox selecteds But not works. Any idea?? $(document).ready(function($){ if ($('#categories-tree-reduce').length) { $('#categories-tree-reduce').trigger('click'); } $(".category-tree input").each(function(index){ if (index > 0 ){ var element = $(this); if( element.prop('checked') ) { var id = $(this).parent('.checkbox'); //click ? } } }); }); Link to comment Share on other sites More sharing options...
EvaF Posted May 28, 2021 Share Posted May 28, 2021 function livisible($element) { return $element.find("li input:checked").length>0} function ulvisible($element) { $element.find('li ul').each(function(index){ var visible = (($(this).find('li ul').length) ? ulvisible($(this)):false) | livisible($(this)); $(this).css('display',visible?'init':'none') }); } to collapse unchecked categories write ulvisible($('ul.category-tree')); Link to comment Share on other sites More sharing options...
Perrotekel Posted May 28, 2021 Author Share Posted May 28, 2021 Thanks, works fine!!!! 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now