[英]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.