Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Is there a method that can be called in componentDidMount() and componentDidUpdate() to activate the menu? #56

Open
U-4-E-A opened this issue Apr 20, 2018 · 0 comments

Comments

@U-4-E-A
Copy link

U-4-E-A commented Apr 20, 2018

I have AdminLTE running in ReactJS but I was wondering there is a method out there for setting the parent li to .active based on the child also being .active? Achieving .active on the is easy with Navlink but setting the parent class is trickier. We would also need to have li.treeview set to li.treeview.menu-open if it has active children too. I have put together the following in jQuery and put it in componentDidMount() and componentDidUpdate() but for some reason the code is not run in those lifecycle events (I suspect it has something to do with not using refs: -

$('ul.sidebar-menu li:not(.treeview):has(a.active)').addClass('active');

The following sets the li.treeview classes by event triggering: -

$('ul.sidebar-menu li.treeview:not(.menu-open)').has('a.active').find('a').trigger( "click" );

As with the code above, this too works but is not being called properly in the lifecycle events. Although is should be pointed out that the second piece of code is doing .trigger("click") on all li.treeview nodes, regardless of whether or they have children with a.active (i.e. in multiple nested menus).

Any help/thoughts/advice?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant