livetabs plugin

written by benjamin on January 28th, 2007 @ 09:17 PM

A lot of dialogs on omdb have tabbed content that you can switch via Javascript. We’ve created a small plugin to extract that functionality.

The ‘livetabs’ plugin for Rails makes it easy to add any number of tabs and tabbed content, that the user can switch via javascript. To install the plugin, use rails plugin script

script/plugin install http://svn.omdb-beta.org/plugins/livetabs

Next you need to copy the javascript, stylesheets and images to your rails public folder. Right now the plugin has just one skin, that is the current omdb-tab-layout. To copy these assets, type

rake livetabs:install:default

To use the tabs, simply add a line like that to your view:

<%= livetabs "One", "Two", "Three" %>

Which will you give three tabs. You can use any number of tabs of course. The pluin will look for partials named like the name of the tab, so in this case for a _one.rhtml, _two.rhtml and _three.rhtml. If you use spaces in your tab names, they will be transformed to underscores. So a tab names “Recent News” will look for a partial called _recent_news.rhtml.

You need to include the default javascripts (javascript_include_tag :defaults) and the livetabs stylesheets (stylesheet_link_tag ‘livetabs’) in your layout.

Here is a small preview, how the tabs will look like.

Post a comment

Options:

Size