Jump to content

Hide categories not selected


Perrotekel
 Share

Recommended Posts

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 ?
							
						}
      				}
      			});

      });

 

 

 

tree.JPG

Share this post


Link to post
Share on other sites

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'));

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More