【问题标题】:how to redirect to tab of another page in rails?如何重定向到rails中另一个页面的选项卡?
【发布时间】:2018-09-26 06:34:39
【问题描述】:

如何重定向到rails中另一个页面的标签? 当我单击第一页的按钮时,当我单击设置时,它会将我重定向到页面的默认选项卡(基本),我想重定向到通知选项卡。

第一页的视图:

.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'

【问题讨论】:

    标签: javascript ruby-on-rails bootstrap-4


    【解决方案1】:

    您可以将 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多