-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
63 lines (38 loc) · 2.04 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
TabbedInterface
===============
Build a tabbed interface very easily. Requires Prototype.
see a working example at http://tab-interface.heroku.com
Install
=======
./script/plugin install git://github.com/jondruse/tabbed_interface.git
Move the ajax-loader.gif from the resources folder to your public images folder, or go make one at http://www.ajaxload.info/. Whatever you do, just make sure you call it ajax-loader.gif.
An example css file is also included in the resources folder.
Example
=======
In this simple example we setup a TabbedInterface with two tabs.
<% tabbed_content do |box| %>
# You don't have to include these. They are the defaults, but this is how you would change them.
<% box.content_wrapper = "tabbed_content" %>
<% box.navigation_wrapper = "tabbed_navigation" %>
<% box.tab_tag = :li %>
<% box.tabs_tag = :ul %>
# Let's add some tabs!
# All you need is a title and a url. Also accepts two options hashes that get passed directly to the link_to_remote call.
<% box.tab("Test One", test_one_path, {:method => :post}, {:class => "different-class"}) %>
<% box.tab("Test Two", test_two_path) %>
<% box.content = capture do %>
# Put your default content here (probably the content for the the first tab, but doesn't have to be)
Default text
<% end %>
<% end %>
The tabbed_content helper yields an object that has two main methods.
#tab
This method will setup a new tab header. Just pass the title and the url to call and update the main content area.
#content
The only requirement is that you use capture (as shown above). This sets the default content for the interface. Then when you click on a different tab, the content will be updated. You can put anything in here, but it will probably be a partial, being that the links use link_to_remote to update the main content area. There are no limitations on how any tabs you can have, or how many interfaces you can have on a page.
Enjoy!
TO-Do's
=======
1. more configurable javascript support
2. tests
Copyright (c) 2009 Jon Druse, released under the MIT license