简体   繁体   中英

Link to tab in other page using link_to in rails 4

How do you link to a different page and activating a tab using link_to from the scaffold generated code.

<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
                root_path, :class => 'btn btn-default' %>

i tried this but it didn't work either:

<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
                root_path('#panel_projects'), :class => 'btn btn-default' %>

Where as #panel_projects is the tab link which i want the users to get to after getting redirected.

Does anybody know how to accomplish this? Preferably without Javascript.

You can use the anchor (find it in the examples ) parameter:

<%= link_to(
      t('.cancel', :default => t('helpers.links.cancel')),
      root_path(anchor: 'panel_projects'), 
      :class => 'btn btn-default') %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM