|
Unobstrusive CSS tabs
Here is the XHTML code used for demo #example :
Initialize tabs
This method is the most simple and convenient.
Indeed, the use of design pattern Singleton allows to recover the unique instance through this function
Initialize tabs with options
You can configure your tabs with an local javascript object.
Go to "Options" tab to see a summary of available options
Initialize tabs by the traditional method
This method is syntactically heavier, it is less easy to manage tabs
Manipulate tabs
Now that the tabs are initialized, you can easily retrieve a precise tab by its index or its unique identifier:
Hide tab
Show tab
Show only the tab
Show tab and panel (select it)
Toggle
Toggle only the tab
Toggle tab and panel (select it)
Custom events
Two events are provided. It allows you to perform specific
actions when the user show/hide a tab. For example, you can define
visual effects from script.aculo.us.
After clicking the two buttons 'Execute', try to show / hide the tab 'Two' (with the buttons below)
show
is called when user show the tab :
hide
is called when the tab is hided :
Select tab
Two methods are proposed: the first is the shortest, in fact, is an alias of the second.
Utility methods
Select first tab
You can select the first created tab with this feature :
Select last tab
You can select the last created tab with this feature :
Custom events
Two events are provided. It allows you to perform specific
actions when the user (un)selects a tab. An example of use can be
seen in the History page, clicking on the tab 'Ajax.History',
for example, the box will appear.
After clicking the two buttons 'Execute', try to select / unselect the tab 'Two'.
select
is called when user select the tab :
unselect
is called when the tab is unselected (generally when the user selects another tab) :
Ajax tab
Prototype.Xtensions.Tabs provides a simple and flexible system allowing you
to load one or several different AJAX applications in a tab. (Almost) everything is customizable!
Automatic loading on selection of tab
Note that if you define the parameters of your request at the initalisation, loading of
the tab via Ajax will be done automatically when selecting the tab.
Also note that the automatic loading by the selection is performed only one single time in the first selection of the tab. This avoids loading the tab whenever the user selects the tab.
Setting up an Ajax request
This method is the most simple and convenient.
Indeed, the use of design pattern Singleton allows to recover the unique instance through this function
In this example, the title of the tab will be changed to 'Loading...' during the loading of the Ajax request :
Here we define the parameters of Ajax Request during the initialization of tabs.
Thus, when selecting the tab, ajax request will be charged.
Note that it is possible to access directly to the 'two' tab object in the callbacks onSuccess(response, json, tabs) and onLoading(tabs). The same mechanism was implemented on all other callbacks provided by Ajax.Request. In this example we define a specified style on panel when Ajax Request is loaded (red background and text in white). When loading the Ajax Request, the panel will contain 'Loading...' :
Details about load/reload
Iframe tab
This method is the most simple and convenient.
Indeed, the use of design pattern Singleton allows to recover the unique instance through this function
Options and xtras features
Sortable tabs (scriptaculous)
It is possible to make the tabs sortable through a dedicated function.
It is a shortcut for the use of component "Sortable" of Scriptaculous.
In the next release...
|
Demo #example
This is first tab
This is second tab (static content)
This is third tab
|