SlickNav icon indicating copy to clipboard operation
SlickNav copied to clipboard

Active state with children visible without user intervention

Open lmartins opened this issue 9 years ago • 5 comments

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 avatar Jan 27 '15 10:01 lmartins

@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.

ComputerWolf avatar Feb 24 '15 15:02 ComputerWolf

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.

dkrmer88 avatar Apr 12 '15 08:04 dkrmer88

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?

Anke avatar May 02 '15 15:05 Anke

@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);
    }
}

andwee avatar Feb 11 '16 09:02 andwee

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.

michaeltlombardi avatar Sep 30 '16 20:09 michaeltlombardi