06.05.2013 Views

Drupal 6 JavaScript and jQuery - Ebook-Cours.com

Drupal 6 JavaScript and jQuery - Ebook-Cours.com

Drupal 6 JavaScript and jQuery - Ebook-Cours.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This is the area that the ID identifies. But there is the additional :not(.uiaccordion).<br />

The ui-accordion class is added by an accordion widget. As with<br />

other behaviors, we add this extra check to ensure if the behavior is run multiple<br />

times, we won't try to repeatedly turn the left column into an accordion widget.<br />

Let's now take a look at the second part of the query:<br />

$('#sidebar-left:not(.ui-accordion)').accordion({<br />

header: 'h2'<br />

});<br />

The <strong>jQuery</strong> UI functions are added onto the main <strong>jQuery</strong> object (we will see how<br />

to do this in our final project). So adding the accordion is as simple as calling the<br />

accordion() method.<br />

[ 305 ]<br />

Chapter 9<br />

That method takes an object literal containing settings. There are over half a dozen<br />

possible settings for the accordion, all documented at http://docs.jquery.<strong>com</strong>/<br />

UI/Accordion/accordion#options, but we will only use one.<br />

We need to tell the accordion effect what element to use as header information. To<br />

explain this, let's take a quick look at the structure of the HTML in the left sidebar:<br />

<br />

<br />

<br />

mbutcher<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Content Management<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Development<br />

<br />

<br />

This material is copyright <strong>and</strong> is licensed for the sole use by Richard Ostheimer on 18th June 2009<br />

2205 hilda ave., , missoula, , 59801

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!