Facebooker Tutorial
Next Lesson → Invite Friends
2.1) Tabs
This lesson shows you how to render a facebook tab control.
FBML tab control is handled by two methods, fb_tabs and fb_tab_item. If you check out the wiki you will see that fb_tabs tag contains some number of fb_tab_item tags. Here is how the tab control is created for this tutorial.
-
Create a method to determine if the current tab is selected or not.
1 2 3 4
#File: app/helpers/application_helper.rb Method: tab_selected? def tab_selected?(section) (section.lessons.first.url_options[:controller] == params[:controller]) end
-
Now create the fb_tabs container and all the fb_tab_items
1 2 3 4 5
# File: app/views/layouts/_section_tabs.rhtml <% fb_tabs do %> <%= section_tab_items() %> <% end %>
Note: fb_tabs method is a little touchy on what the block that you pass it does. The is why I factored out the code that returns the tab_items.1 2 3 4 5 6
#File: app/helpers/application_helper.rb Method: section_tab_items def section_tab_items LessonOutline.outline.sections.collect do |section| fb_tab_item(section.name, url_for(section.lessons.first.url_options), :selected => tab_selected?(section) ) end.join("\n") end
Next Lesson → Invite Friends
Comment Section for Tabs


Ace Suaresden 6 oktober 2009
Steve Hullden 23 mars 2009
Evan Andersonden 10 september 2008
David Clementsden 6 mars 2008
Zia Syedden 5 mars 2008
Jorge Miramontesden 28 februari 2008
David Clementsden 27 februari 2008
Jorge Miramontesden 27 februari 2008
David Fugereden 18 februari 2008