My client has a taxonomy hierarchy like this.
-tax1
--subtax1
---item1
---item2
--subtax2
---item1b
---item2b
--subtax3
-tax2
etc..
If the user clicks into item1 (a child of subtax1 + a grandchild of tax1)
item1 gets a class of 'active' and 'open'
but subtax1 and tax1 have a class of 'closed'
I added the following jquery to make sure the parents of these nested items remain open when selected
$(document).ready(function() {
$("#block-taxonomyblocks-0 .content ul li ul li ul li.active").parent().parent().addClass("open").addClass("active").removeClass("closed");
$("#block-taxonomyblocks-0 .content ul li ul li ul li.active").parent().parent().find("span").addClass("open").removeClass("closed");
$("#block-taxonomyblocks-0 .content ul li ul li ul li.active").parent().parent().parent().parent().find("span").addClass("open").removeClass("closed");
$("#block-taxonomyblocks-0 .content ul li ul li ul li.active").parent().parent().parent().parent().addClass("open").addClass("active").removeClass("closed");
$("#block-taxonomyblocks-0 .content ul li ul li.active").parent().parent().addClass("open").addClass("active").removeClass("closed");
$("#block-taxonomyblocks-0 .content ul li ul li.active").parent().parent().find("span").addClass("open").removeClass("closed");
$("#block-taxonomyblocks-0 .content ul li ul li.active").parent().parent().parent().parent().addClass("open").addClass("active").removeClass("closed");
});
I haven't tested with a blank theme to see if this occurs naturally, but I figured I'd share the solution that works for me.
Comments
Comment #0.0
drjonez commentedNeeded to remove a line from the code that was adding 'open' class to non-open spans
Comment #1
fantom84 commentedit works for me, but in your code, there is a small error. you use the .find(), but it is better to use .children()
Here is the code that I corrected:
});
Comment #1.0
fantom84 commentedadded "grandchild" instead of "child" for better understanding