I have Nav
with items:
[
'label' => 'All',
'url' => ['project/index'],
],
[
'label' => 'Done',
'url' => ['project/index', 'assigned' => 'done'],
],
But both of them have an active
class when I go to project/index&assigned=done. How can I force to attach this class only if item's url
is strictly equal to $route
value?
Nav
widget will make an item active when its route and parameters match $route
(if not set, it will use the route of the current request) and $params
(if not set, it will use $_GET).
Your first item will always be active if the route is project/index
(take a look here).
You should try this for example :
[
'label' => 'All',
'url' => ['project/index', 'assigned' => 'not-done'],
],
[
'label' => 'Done',
'url' => ['project/index', 'assigned' => 'done'],
],
Read more about how Nav
widget set an item active or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With