Javascript 如何重定向到rails中另一页的选项卡?
如何重定向到rails中另一页的选项卡? 当我单击第一页的按钮时,它会将我重定向到该页的默认选项卡Basic。当我单击“设置”时,我想重定向到“通知”选项卡 第1页视图:Javascript 如何重定向到rails中另一页的选项卡?,javascript,ruby-on-rails,bootstrap-4,Javascript,Ruby On Rails,Bootstrap 4,如何重定向到rails中另一页的选项卡? 当我单击第一页的按钮时,它会将我重定向到该页的默认选项卡Basic。当我单击“设置”时,我想重定向到“通知”选项卡 第1页视图: .button %a{:href => edit_student_path(current_student)} settings 选项卡页的视图: %ul.nav.nav-pills %li.active %a{"data-toggle" => "tab", :h
.button
%a{:href => edit_student_path(current_student)}
settings
选项卡页的视图:
%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'
您可以将css类作为参数传递给active,下面是一个示例: 使用按钮查看:
.button
%a{:href => edit_student_path(current_student, tab: "notification")}
settings
选项卡:
%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