1

I have a show page which has 3 tabs. The third tab has a add new action and when the item is created the page redirects to the first tab by default . How can i pass the id of the third tab in the redirect path of the create action?

i.e redirect_to manufacturer_path(@item.manufacturer.id) redirects to third tab in manufacturer show page

Pallavi Hegde
  • 219
  • 2
  • 15
  • redirect_to some_path(:format => "divId"), i think this u need to call up div from url – chaitanya Jun 01 '16 at 10:21
  • But, the url doesnt have the id . U just switch between the tabs in the show page – Pallavi Hegde Jun 01 '16 at 10:26
  • i think u need to assign ids to those tabs and need to pass extra param from redirect to eg. manufacturer_path(@item.manufacturer.id, :manufacturer => true) and write jquery (to show / hide divs ) under if params[:manufacturer] ... – chaitanya Jun 01 '16 at 10:42
  • could you tell me what the :manufacturer => true does here? – Pallavi Hegde Jun 01 '16 at 10:47
  • it's just extra param so on show page if you received that param on page u can add javascript on that page below condition like <% if params[:manufactuer]%> show / hide divs <% end %> – chaitanya Jun 01 '16 at 10:58
  • hey the divs are showing correctly.. i just want the page to go a particular when it is redirected after create – Pallavi Hegde Jun 01 '16 at 17:20

1 Answers1

1

Use redirection to anchor:

redirect_to manufacturer_path(@item.manufacturer.id), anchor: "tab3"

BUT it seems that browser will not act scrolling to it, so, also you have to just render a proper part of view also claused in if condition.

The anchor will be searched by a browser in case for id="tab3" followed by name="tab3". See the explanation.

Community
  • 1
  • 1
Малъ Скрылевъ
  • 16,187
  • 5
  • 56
  • 69