arielsalminen / TinyNav.js

Responsive navigation plugin that weighs just 443 bytes
http://tinynav.viljamis.com/
635 stars 207 forks source link

Specify depth of navigation #37

Open LRotherfield opened 11 years ago

LRotherfield commented 11 years ago

I have been working on a project that has a mega menu and also a side menu. Because of the duplicate navigation I only wanted the top navigation to show the first level of nav once its made into a select. The alterations in this pull request add another settings key "depth" which allows the developer to set a specific depth to iterate to.

An example:

$(".navigation_one > ul").tinyNav({
  active: 'current',
  depth: 2
});
bigsweater commented 11 years ago

+1

Nicely done.

ghost commented 11 years ago

There's a bug with the implementation, please see #39

magmanoid commented 6 years ago

I would recomend to do it by update a library on line 40 Change: options += '<option value="' + $(this).attr('href') + '">'; To: options += '<option value="' + $(this).attr('href') + '" class="menuLevel-'+ $(this).parents('ul, ol').length +'">';

Then all options have own class with level specification: class="menuLevel-1" class="menuLevel-2" class="menuLevel-3"

And you can easy hide them in css: .menuLevel-3{ display:hide; }