Christian Whitesides
Joined
Activity
🎉 Thanks so much, Chris!
That looks much nicer. Thanks for the tip! And thanks again for taking the time to respond. I really appreciate it.
Thanks, Chris! Just what I needed. Each tab is tied to an individual controller (in order to avoid writing custom actions), so I just created the following helper:
def index_based_on_controller(controller)
case controller
when "user_books"
0
when "user_books/want_to_read"
1
when "user_books/reading_now"
2
when "user_books/finished"
3
when "user_books/recommended"
4
when "user_books/dropped"
5
end
end
Then I used the helper in my div with the navigation, like so:
<div data-controller="filter-statuses" data-filter-statuses-index="<%= index_based_on_controller(params[:controller]) %>" >
Worked out great! If there's a better way to write the helper above, please let me know. Once again, thanks for your help!
I have a version of your Tabs tailwindcss-stimulus component up and running. However, I'm struggling to figure out how to save an active tab so that it remains active after a page reload. Right now a page reload just kicks the nav back to the tab at index zero...
localStorage
seems to be the recommended way to go, but the help I find everywhere is strictly jquery-based. If you have any suggestions, I'd appreciate it! 🙏