Ask A Question


You’re not receiving notifications from this thread.

Struggling with active nav tabs setting active class

spacerobotTR asked in Rails

I have an issue I haven't been able to solve. I have a products page set up with some different sections via bootstrap 4 nav tabs. General Info, Images, Pricing etc. I am trying to make it so that if I upload new product images and it reloads the screen it stays on the images nav tab by setting that tab active. I have been struggling to get that working though. Here is my page:

<%= form_with(model: admin_product, local: true) do |form| %>
 <div class="nav-tabs-top nav-responsive-sm">
   <ul class="nav nav-tabs">
     <li class="nav-item">
       <a class="nav-link active" data-toggle="tab" href="#item-info" >Product Info</a>
     <li class="nav-item">
       <a class="nav-link" data-toggle="tab" href="#item-pricing" >Product Pricing</a>
     <li class="nav-item">
       <a class="nav-link" data-toggle="tab" href="#item-images" >Product Images</a>

   <div class="tab-content">

   <div class="tab-pane fade show active" id="item-info">

   <div class="tab-pane fade" id="item-pricing">

   <div class="tab-pane fade" id="item-images">

<% end %> 

Any ideas on how I can set this up?

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,168+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.