SlickNav
SlickNav copied to clipboard
Active state with children visible without user intervention
Would be quite useful to have an option to expand the tree when any of the children options would have an active state.
This would allow to use the menu to quickly jump around between pages of the same section, without forcing the user to go through the entire navigation tree for each page.
Is this something in the plans for the future?
@lmartins, you would need to somehow pass the active item to the script on initialization. A few solutions I can think of would be to add an active
class to the original menu and then SlickNav could check each element for this class, or it could analyze the current url and check against the child url, but this could be prone to errors. Each element could also have a unique ID that could get passed, but that does not seem simple either. Any input on functionality would be helpful.
I needed the same feature so I added it with one simple line of code:
if (!settings.showChildren){
if(!settings.openClass || !$(this).hasClass(settings.openClass)){
$this._visibilityToggle(data.children, null, false, null, true);
}
}
jquery.slicknav-js -- line 182 Now you can add an option with the name "openClass" to the constructor and all submenus with that class will stay open.
Hi,
I like this plugin as it allows the use of dynamically created navigations; thanks for letting us use it.
Since I also need to let submenus open if selected/active, I tried dkrmer88's code, but it opens alls submenus by default.
How about integrating support for jquery.cookie.js, which often is installed anyway and used by other plugins?
@dkrmer88 Thank you for the fix.
I had to change it a little bit, so that not every submenu is active:
if (!settings.showChildren){
if(settings.openClass && $(this).hasClass(settings.openClass)){
$this._visibilityToggle(data.children, null, false, null, true);
}
}
Neither @andwee nor @henrijs's fixes seem to keep all nav items from being open for me. Investigating, but I'm no javascript dev. :) Will report back if I am able to get it to work properly.