4 ms·
I love stimulus. And Hotwire. I find everything more maintainable and faster to developer when rails on the centre of the universe. Obviously a personal prefere
by RileyJames 3y ago
I love stimulus. And Hotwire. I find everything more maintainable and faster to developer when rails on the centre of the universe. Obviously a personal preference.
I faced a similar display toggle-able use case for form fields recently.
I did find that I used stimulus to hide the fields there was a slightly “flicker” as they appeared and then were hidden in the connect() function.
It didn’t affect my use case, as I could default hide and then toggle them to appear with stimulus.
But in the event they should appear by default and then be hidden based on some logic within the stimulus controller, is there a better way to handle this?
- ignurant 3y agoI usually conditionally include the visibility toggle class from the erb side, so the first time it renders as html it has the toggle correctly initiated. I can see situations where the visibility logic is hard or impossible from the Ruby side, but I haven’t had this issue yet.
- hbroadbent 3y agoUnfortunately I haven't come up with a good solution either beyond hiding the element with CSS, and then showing it when the controller connects (which isn't ideal). I'd love any suggestions though for different techniques