We've moved discussions to Discord

how to set tab on js tabs stimulus controller from rails query parameter

Roberto Plancarte
Hi, the tab_controller.js isn't inside the javascript folder and I would like to get the current open tab in from a query parameter and pass it from the rails controller to the js tab controller so that a tab remains open through refreshes. Is there a way to do this now, or do I need to write my own stimulus tab_controller.js?
Chris Oliver
Hey 

It's in https://github.com/excid3/tailwindcss-stimulus-components#tabs

You can set the data-tabs-index="1" attribute in the HTML so it will select the tab you want by default.
John Quarto-vonTivadar
although this seems a bit out of date (from 2019), specifically you would put this
data-tabs-index="1"
on the line that has the stimulus controller
data-controller="tabs"
with a value corresponding to the 0-th based tab. so above, the value of 1 indicates you want the second tab to be active by default.
Roberto Plancarte
thx
Roberto Plancarte
Hi, the tab_controller.js isn't inside the javascript folder and I would like to get the current open tab in from a query parameter and pass it from the rails controller to the js tab controller so that a tab remains open through refreshes. Is there a way to do this now, or do I need to write my own stimulus tab_controller.js?
Chris Oliver
Hey 

It's in https://github.com/excid3/tailwindcss-stimulus-components#tabs

You can set the data-tabs-index="1" attribute in the HTML so it will select the tab you want by default.
John Quarto-vonTivadar
although this seems a bit out of date (from 2019), specifically you would put this
data-tabs-index="1"
on the line that has the stimulus controller
data-controller="tabs"
with a value corresponding to the 0-th based tab. so above, the value of 1 indicates you want the second tab to be active by default.
Roberto Plancarte
thx
Notifications
You’re not receiving notifications from this thread.
© 2022 Jumpstart Pro by GoRails, LLC