Replies: 7 comments 8 replies
-
How to do that? close the dropdown menu when one of the items is being clicked, a onClick event using vuejs? |
Beta Was this translation helpful? Give feedback.
-
Hey peeps, Not currently possible using only the data attributes, I'll have to build a You can do this with the JavaScript API though using the function callbacks. ETA couple of weeks! Cheers, |
Beta Was this translation helpful? Give feedback.
-
Try with this It worked for me
|
Beta Was this translation helpful? Give feedback.
-
Any Updates on this problem? No fix solution from Maintainer yet? |
Beta Was this translation helpful? Give feedback.
-
This is now possible if you are in const theDropdown = FlowbiteInstances.getInstance('Dropdown', 'the-dropdown-id');
theDropdown.hide(); More info on FlowbiteInstances: https://flowbite.com/docs/getting-started/javascript/#instance-manager If you are using older version, something like his should work (taken from @jamilbk 's reply): const theDropdown = new Dropdown(
document.getElementById('the-dropdown-id'),
document.getElementById('the-dropdown-trigger-id')
);
theDropdown.hide(); // or sth else it looks weird if you are using data attributes to create the dropdown, but it did the job. |
Beta Was this translation helpful? Give feedback.
-
I can hide the dropdown ul with an onClick in the li, but next time the button is clicked, it remains hidden. Not until an additional click will it toggle back to visible. So hiding it without toggling it is not a proper solution. |
Beta Was this translation helpful? Give feedback.
-
lol I seriously thought it was just me not understanding Flowbite, because this is such a vital and basic thing to want to do I would expect it to exist. No wonder it was not documented. Mind you, I have been delayed several times because of this exact issue, as we had to implement custom functionality using Flowbite components. Further more, the documentation has been quite misleading by saying the first parameter to e.g. "new Accordion()" is a reference to the HTML element, as fetched via For those interested in a workaround, you can simply define your own components, as is somewhat documented, but it is obviously not ideal because the automatic initialization will not work, and you even have to attach your own event handlers on existing buttons. I did manage to get certain things to work the automatic way, by hacking it in similar ways to @nchankov, but it caused other problems that I then wasted time trying to solve. Of course, I have no idea what version of Flowbite we are using or how to check it, but the instance manager does not seem to be available, so presumably we are not on 2.0... I even tried asking earlier, but no luck there: #752 |
Beta Was this translation helpful? Give feedback.
-
Is it possible to close/collapse the dropdown when the user clicks on one of its items without using the Javascript API?
Dropdowns already collapse when clicking outside them. Would it be possible to configure the dropdown widget via data attributes to toggle collapsing the dropdown when clicking on its items?
Beta Was this translation helpful? Give feedback.
All reactions