html - <li> only visible when parent has css class="current" -


I have a list of categories called taxonomies:

Rail code is here:

  & lt; Div id = "taxonomies" class = "sidebar-item" & gt; Do & lt;% @ taxonomies.each Classification | & Gt%; & Lt; Ul class = "navigation-list" & gt; & Lt;% taxonomy.root.children.each Do | Taxon | | & Gt%; & Lt; Li & lt;% = 'class = "current" if @taxon and ([@taxon] + taxon.ancestors) .include? (Taxon%) & gt; & Gt; & Lt;% = link_to taxon.name, seo_url taxon)% & gt; & Lt; / Li & gt; & Lt;% if @ taxon.nil? & Gt%; & Lt;% else% & gt; & Lt;% @ taxon.children.each do | Taxon |%> & Lt; Li & gt; & Lt;% = link_to taxon.name, seo_url (taxon)% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt;% end% & gt; & Lt;% end% & gt; & Lt; / Ul & gt; & Lt;% end% & gt; & Lt; / Div & gt;  

The problem is just right that if I click to see a specific classification then it shows me all the parents' children. Then ...

Category 1 Justice 1 Justice 2 Category 2 Justice 1 Justice 2 Category 3 Justice 1 Justice 2

When I want to: Category 1 Justice 1 Justice 2 Category 2 Category 3

The CSS class is currently engage in the selected category. I had some kind of & lt;% if: class => 'on%' show light, and do not show anything.

Is anyone possible if this is possible?

Can not you reuse the same condition to add the class attribute?

If @tex and ([Taxon] taxon.ancestors) .include? (Taxon)

then you will have:

  & lt;% taxonomy.root.children Do each. Taxon | & Gt%; & Lt; Li & lt;% = 'class = "current" if @taxon and ([@taxon] + taxon.ancestors) .include? (Taxon%) & gt; & Gt; & Lt;% = link_to taxon.name, seo_url taxon)% & gt; & Lt; / Li & gt; Include & lt;% if @taxon and ([taxon] + taxon.nosterors)? Include (Taxon)% & gt; & Lt;% @ taxon.children.each do | Taxon |%> & Lt; Li & gt; & Lt;% = link_to taxon.name, seo_url (taxon)% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt;% end% & gt; & Lt;% end% & gt;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -