简体   繁体   中英

how to redirect to tab of another page in rails?

how to redirect to the tab of another page in rails? When I click on the button of the first page it redirects me to the default tab(basic) of the page when I click on settings, I want to redirect to the notification tab.

view of 1st page:

.button
    %a{:href => edit_student_path(current_student)}
        settings 

view of tab page:

%ul.nav.nav-pills
    %li.active
        %a{"data-toggle" => "tab", :href => "#student-basic", :role => "tab"} basic-info
    %li
        %a{"data-toggle" => "tab", :href => "#student-notification", :role => "tab"} notification


.tab-content
    #student-basic.tab-pane.active
        = render 'basic_info_form'
    #student-notifications.tab-pane
        = render 'notifications_form'

You can pass the css class active as parameter, here is an example:

View with button:

.button
    %a{:href => edit_student_path(current_student, tab: "notification")}
        settings 

Tabs:

%ul.nav.nav-pills
    %li{ class: ( "active" if params[:tab] == "tab" ) }
        %a{"data-toggle" => "tab", :href => "#student-basic", :role => "tab"} basic-info
    %li{ class: ( "active" if params[:tab] == "notification" ) }
        %a{"data-toggle" => "tab", :href => "#student-notification", :role => "tab"} notification

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