@@ -13,21 +13,21 @@ Maybe you will find them useful as well.
1313These include ... (just one helper for now)
1414
1515
16- TabsRenderer
16+ TabsHelper
1717----------------------------------------------------------------
1818
1919This helper simplifies the code required to use JQuery UIs Tabs plugin.
2020
21- There are 3 steps to rendering a tab ... initialize, create and render .
21+ Example usage .. .
2222
23- <% tabs = TabsRenderer.new(self) %>
24- <% tabs .create('tab_one', 'Tab 1') do %>
23+ <% tabs_for do |tab| %>
24+ <% tab .create('tab_one', 'Tab 1') do %>
2525 # ... insert tab contents
2626 <% end %>
27- <% tabs .create('tab_two', 'Tab 2') do %>
27+ <% tab .create('tab_two', 'Tab 2') do %>
2828 # ... insert tab contents
2929 <% end %>
30- <%= tabs.render %>
30+ <% end %>
3131
3232The above will generate this HTML in your view:
3333
@@ -49,43 +49,21 @@ Tabs will be rendered in the order you create them.
4949You can easily render a tab conditionally by appending your condition to the end of
5050the 'create' block as such ...
5151
52- <% tabs .create('profile_tab', 'Your Profile') do %>
52+ <% tab .create('profile_tab', 'Your Profile') do %>
5353 # ... insert tab contents
5454 <% end unless @current_user.nil? %>
5555
5656You can pass HTML options to either the parent DIV or any individual tab's
5757DIV as you like ...
5858
59- <% tabs = TabsRenderer.new(self, :class = 'flora') %>
60- <% tabs .create('tab_one', 'Tab 1', :style => 'background: #FFF') do %>
59+ <% tabs_for( :class => 'zippy') do |tab| %>
60+ <% tab .create('tab_one', 'Tab 1', :style => 'background: #FFF') do %>
6161 # ... insert tab contents
6262 <% end %>
63- <%= tabs.render %>
63+ <% end %>
6464
6565The default DOM ID for the parent div is ... id="tabs" ... unless you pass in an HTML
6666option with a different value.
6767
68- Also optional, you can now call TabsRenderer.new with a block parameter, and create
69- the tabs that way.
7068
71- <% tabs = TabsRenderer.new(self) do |tab| %>
72- <% tab.create('tab_one', 'Tab 1') do %>
73- # ... insert tab contents
74- <% end %>
75- <% tab.create('tab_two', 'Tab 2') do %>
76- # ... insert tab contents
77- <% end %>
78- <% end %>
79- <%= tabs.render %>
80-
81- ##########################################################################
82- Now works as:
83- <% tabs_for do |tab| %>
84- <% tab.create('tab_one', 'Tab 1') do %>
85- # ... insert tab contents
86- <% end %>
87- <% tab.create('tab_two', 'Tab 2') do %>
88- # ... insert tab contents
89- <% end %>
90- <% end %>
9169
0 commit comments