Tailwind on Rails #140 Click outside to close Menu with Stimulus-Use
12/08/2023 (9 months ago)
Click outside element to hide it
- this might be one of the most common javascript tasks!
We will leverage Stimulus-use and it's clickOutside behaviour to trigger an action on a stimulus controller. In our case - to close the dropdown menu.
Episode source code: https://github.com/corsego/138-tailwind-layout/commit/f58de741ddd87b52ededc1fcee5b7d0b8f67f229
Based on this blogpost: https://blog.corsego.com/tailwindcss-dropdown
P.S. 🙈 Really, I just forgot to include this feature in the previous episode, so here you go. This might be my shortest episode yet!
0
Sign in to join the conversation
Featured in playlists
+2
Tailwind on Rails
Stop copypasting CSS and Javascript UI elements!
Learn to write your own!
Really, there are like 50 classes that you need to remember and you're set for life!
Recommended based on what you are watching now
52:20
Free Ruby on Rails #75 ActsAsVotable: likes, bookmarks, hotwire, vote scopes, cached votes
21/04/2022 (about 2 years ago)
44:58
Free #57 Database Architecture 101: Building an ERD (Entity Relationship Diagram) for UberEats clone
10/10/2021 (over 2 years ago)
17:58
Free Ruby on Rails #58 Nested Resources
18/10/2021 (over 2 years ago)
10:03
Free Ruby on Rails #153 Refactoring Hotwire Modals
21/11/2023 (6 months ago)