Professional jQuery™ by Cesar Otero & Rob Larsen

Professional jQuery™ by Cesar Otero & Rob Larsen

Author:Cesar Otero & Rob Larsen
Language: eng
Format: epub
Publisher: John Wiley & Sons
Published: 2012-03-01T16:00:00+00:00


Table 8-5 lists some of the options available when working with $.tabs(). For the full list of options, see the documentation at http://jqueryui.com/demos/tabs/

Table 8.5: Tab Options

OPTION ACCEPTS DESCRIPTION

disabled Boolean An array containing the position of the tabs that should be disabled when the widget is initialized.

event String The event used for selecting a tab. This commonly allows tabs to change on mouseover instead of a standard click.

fx Options, Array fx allows you to set animations for showing and hiding tab content.

panelTemplate String If you’re using Ajax tabs, then you can use panelTemplate to create default HTML from which the new tab panels will be generated.

selected Number This zero-based integer sets the position of the initially selected tab.

spinner String An HTML string used to display a “spinner” or some other indication that the tab panel is loading. Requires a span in the a tag of the title.

tabTemplate String The HTML template from which new tabs are generated.

Accordion

Accordion widgets, similarly to tabs, are a great way to display and categorize a large amount of information. This widget is an expandable/collapsible box. It’s not meant to have all of its content expanded at the same time, but rather to display one “slice” of content at a time.

Table 8-6 illustrates the various accordion methods.

Table 8.6: Available $.accordion Methods

METHOD DESCRIPTION

$(selector).accordion(); Initializes an accordion widget.

$(selector).accordion( “destroy” ); Removes the accordion widget completely. This option rolls the selected element back to its initial state.

$(selector).accordion( “disable” ); Disables the accordion widget.

$(selector).accordion( “enable” ); Enables the accordion widget.

$(selector).accordion( “option” , optionName , [value] ); Get or set any accordion option. If the third argument is omitted, acts as a getter. Otherwise, it sets the optionName with the provided value.

$(selector).accordion( “widget” ); Returns the .ui-accordion element.

$(selector).accordion( “activate” , index ); Activates a content part of the accordion widget. The index indicates the zero-indexed number matching the position of the header to close or a selector matching an element.

$(selector).accordion( “resize” ); Recomputes the heights of the accordion widget contents.

The required markup for an accordion is a div with nested headers, where each header contains a link. The content is placed in a nested div following the header, as the following example illustrates:

<!DOCTYPE html> <html> <head> <link href=”css/ui-lightness/jquery-ui-1.8.13.custom.css” rel=”stylesheet” /> <script src=“http://code.jquery.com/jquery-1.7.1.js”></script> <script src=”js/jquery-ui-1.8.13.custom.min.js”></script> <script $(function() { $( “#accordion” ).accordion(); }); </script> </head> <body> <div id=”accordion”> <h3><a href=”#”>First header</a></h3> <div>First content</div> <h3><a href=”#”>Second header</a></h3> <div>Second content</div> </div> </body> </html>

Code snippet is from accordion.txt



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.