Tabs
A jQuery plugin that provides dynamic tab functionality to transition through panes of local content. Uses CSS transitions to perform the animation.
Comes with a markup API that allows running the plugin without writing a single line of JavaScript. This is Responsive's first class API and should be your first consideration when using a plugin.
Example
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
The Markup
<div data-tabs="">
<ul class="tabs">
<li class="tab-active"><a href="#">tab1</a></li>
<li><a href="#">tab2</a></li>
</ul>
<div class="tab-pane-active">
....
</div>
<div>...</div>
</div>
Methods
The accordion exposes the following method signatures.
- .tabs(index)
- Initialises the plugin with an optional index parameter. A zero based indicator for which tab to show.
Events
The accordion exposes the following events allowing the developer to tap into its behaviour.
- show.tabs.responsive
- This event is fired immediately when the plugins
show
instance method is invoked. - shown.tabs.responsive
- This event is fired when the plugins
shown
instance method is invoked once the tab has completed the animation and the new pane is visible.
Data API
The tabs default behaviour is bound using a markup API that allows running the plugin without writing a single line of JavaScript. If you need to override this behaviour the following code will allow you to do so.
// Override the default behaviour
$(document).off("ready.tabs.responsive")
.on("ready.tabs.responsive", function (event) {
// Your custom behaviour...
});
// Override the default tabs control click behaviour
$("[data-tabs]").off("click.tabs.responsive")
.on("click.tabs.responsive", "ul.tabs > li > a", function (event) {
// Your custom behaviour...
});
// Bind to the show event.
$("YOUR_SELECTOR").on("show.tabs.responsive", function(event) {
// Your custom behaviour...
});
// Bind to the shown event.
$("YOUR_SELECTOR").on("shown.tabs.responsive", function(event) {
// Your custom behaviour...
});