简体   繁体   English

如何在application.html.erb以外的视图中添加垂直导航或侧栏,并使它可用于某些视图(Ruby on Rails)?

[英]How to have add a vertical navigation or side bar, in a view other than application.html.erb and make it available to certain views, Ruby on Rails?

My tabs view look like this (Remember this is not part of application.html.erb, since I need the tabs to be available only to certain specific pages): 我的标签视图如下所示(请记住,这不是application.html.erb的一部分,因为我需要这些标签仅对某些特定页面可用):

<div>
<div class="tabbable tabs-left">
<ul class="nav nav-tabs nav-stacked">
    <li class="active">
        <a href="settings_mail">Mail Settings</a>
    </li>
    <li>
        <a href="settings_text">Text Settings</a>
    </li>
</ul>   
</div>

But, on clicking on any of the above tabs, the vertical tabs disappear and goes to the respective views. 但是,单击以上任何一个选项卡,垂直选项卡就会消失并转到相应的视图。 I would like to retain the tabs in each page it navigates to, any pointers are welcome. 我想保留其导航到的每个页面中的选项卡,欢迎使用任何指针。

How about using something like 如何使用类似的东西

layout "other_layout"

in the relevant controllers? 在相关的控制器中? Like explained in http://guides.rubyonrails.org/layouts_and_rendering.html , "2.2.12.1 Specifying Layouts for Controllers" 就像http://guides.rubyonrails.org/layouts_and_rendering.html中的“ 2.2.12.1指定控制器的布局”​​中所述

You can use yield :tag in your layout and use 您可以在布局中使用yield:tag并使用

content_for :tag do
  "your tabs"
end

in your views where you want tabs and don't put content_for method in view where you don't want these tabs. 在您希望使用标签的视图中不要将content_for方法放在不需要这些标签的视图中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Application.html.erb上添加到其他视图的链接? - How to add links on Application.html.erb to other views ? 在rails应用程序的ruby中使用application.html.erb以外的布局? - Using a layout other than application.html.erb in ruby on rails application? 可以查看是否无法在Rails中的ruby中扩展“ application / application.html.erb”? - can view not extend “application/application.html.erb” in ruby on rails? Ruby on Rails视图没有引入application.html.erb布局 - Ruby on Rails view not pulling in application.html.erb layout 我在application.html.erb中有部分内容,如何在某些视图中删除它? - I have a partial in application.html.erb, how do I remove it on certain views? Rails:如何在视图中而不是application.html.erb中包括元标记? - Rails: How to include meta tags in views and not in application.html.erb? 如何在Rails中使实例变量可用于application.html.erb文件? - How do you make an instance variable available to the application.html.erb file in Rails? 骨干Rails:如何在application.html.erb中添加HTML的javascript - Backbone Rails: How to add javascript for HTML in application.html.erb 如何将表单添加到application.html.erb页面ruby - how to add form to application.html.erb page ruby Rails在application.html.erb中使异常 - Rails make exception in the application.html.erb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM