jQuery Menu: Dropdown, iPod Drilldown, and Flyout styles with ARIA Support and ThemeRoller Ready

How it works

Required markup

The menu plugin was written with progressive enhancement in mind: first mark up a basic and functional unordered list of links, then layer on complex styles and functionality. (Ideally the advanced functionality will only be applied if the device is capable of rendering it correctly. We’ve developed a capabilities test to ensure that the appropriate experience is delivered to the a device — read more at A List Apart.)

 

List markup must conform to the following format to work with this plugin:

*  *  *

 

Run the script on DOM ready

Calling the menu plugin departs slightly from how jQuery normally works. Instead of “find something, act on it,” you attach the plugin to the link or button selector and pass in the content as an option. We deviated from the standard format so that we could reference the link/button with low overhead, and also make it possible to use content that’s loaded to the page via AJAX.

As shown below, all options are passed in using object notation (see full list of options below):

$(document).ready(function(){
$('#myMenuButton').menu({
content: $('#myContent').html(), 
maxHeight: 180,
positionOpts: { offsetX: 10, offsetY: 20 },
showSpeed: 300
});
});

Be Sociable, Share!

Leave a comment