jeudi 29 septembre 2016

How can I get multi-leveled navigation to work with simple navigation in Rails?

I am trying to get a navigation bar to have three levels of options. In my config/navigation.rb, I have my nav-bar options, then I include an item for each thing in my collection.

navigation.items do |primary|
primary.dom_attributes = { class: 'usa-unstyled-list' }

# Menu item highlighting will automatically adjust as routes are updated and specified.
primary.item :admin_route_link, 'ADMIN', root_path, if: proc { @is_admin == true }, html: { class: 'navitem has-sub-menu', title: 'Admin' } do |admin_links|
  admin_links.dom_attributes = { class: 'sub-nav-menu' }
    admin_links.item :set_current_thing_link, 'THING' + current_fco, '', if: proc { @is_superuser == true }, html: { class: 'sub-navitem', title: 'CURRENT FCO' } do |things|
        @things.each do |thing|
          thing.item :set_current_thing_link, thing['label'], '', true, html: { class: 'sub-navitem', title: thing['label'] }
        end

      end
    end
  end
end

You can see i am trying to make a third level of depth here. When I run this, all the third-level things get rendered...but they don't stay hidden until you highlight the parent like the second level items do. They look like second level items and appear in the same drop-down. Are there some special styles I should be using that other people use in conjunction with simple-navigation?




Aucun commentaire:

Enregistrer un commentaire