I need to implement a Dropdown menu component which is made in Flowbite, and utilized inside a VUEJS project. The Issue with this dropdown is that it doesnt hide when someone clicks a link inside it. So I need to implement the behavior. Can I have help please with a first step and tell me how to know, using just pure javascript, when a router link link has been clicked?
Asked
Active
Viewed 103 times
0
-
Easiest solution would be to replace `
` with normal text and add an onClick method where you can first toggle the dropdown menu visibility and then programmatically activate the navigation. – yoduh Mar 16 '23 at 13:43 -
@yoduh, actually, if I replace the
for an tag I wouldnt do any code because the tag refreshes the page, so It will close the dropdown menu, but what would be the reason to do that, because when you use router-link links you go quickly to the already catched route – FerchoCarcho Mar 16 '23 at 14:05 -
By [programmatic navigation](https://router.vuejs.org/guide/essentials/navigation.html) I mean using `router.push` which still navigates using vue-router but in your script code instead of in the template. Don't replace `
` with `` but instead just replace with plain text (styled if you want to look like a link). When clicked it should activate a method. By executing the navigation in a method you can perform other side effects first like closing your menu. – yoduh Mar 16 '23 at 14:38