Rails_jquery_ajax_tabs is a project mainly written in RUBY and JAVASCRIPT, it's free.
Horizontal tabs menu using JQuery UI tabs, fetching content through Ajax from a Rails server.
How to implement horizontal tabs menu using JQuery UI tabs, fetching content through Ajax, from a Rails server.
Steps:
Create the Rails app, use the -d option to set the database adaptor. rails -d postgresql rails_jquery_ajax_tabs
Setup controller and views to be tabbed. script/generate controller about tab1 tab2 tab3 tab4
Download and add jquery.js, jquery-ui.js to the rails app directory public/javascripts and jquery-ui stylesheet to public/stylesheets, from http://jqueryui.com/download
Create layout with jquery javascript files and stylesheet.
setup up tabs markup in layout, match the link 'title' attribute and the content container's id, otherwise jquery dynamically creates the container. Using links pointing to the server instead of named anchors inside the same document causes jquery ui tabs to ajaxify the tabs behavior.
Create jquery tabs in application.js $(document).ready(function(){ $("#tabs").tabs(); });
create tab content views in views/about/ e.g. tab1.html.erb :
Find me in app/views/about/tab1.html.erb
turn off layout in controller if request.xhr?
layout :determined_by_request
protected
def determined_by_request if request.xhr? return false else 'application' end end
set up routes in config/routes.rb:
map.root :controller => "about", :action => "tab1"
References: http://docs.jquery.com/UI/Tabs http://jqueryui.com/demos/tabs/ Similar implementation using prototype: http://www.eduvoyage.com/2008/9/26/ajax-tabs-and-rails and http://www.eduvoyage.com/2009/3/14/ajax-tabs-and-rails-2