Vous êtes sur la page 1sur 2

YUI Library: Menu 2008-2-19 v2.

5
Simple Use Case: YAHOO.widget.Menu Key Interesting Moments in Menu YAHOO.widget.Menu:
See online docs for a complete list of Menu’s Custom Events. Properties
Markup (optional, using standard module format): beforeRenderEvent renderEvent parent
<div id="mymenu">
renderEvent beforeShowEvent element
<div class="bd"> id
<ul> showEvent / hideEvent beforeHideEvent
All Menu events are YUI Custom Events (see Event Utility docs); subscribe to these events
<li><a href=” … ”>item one</a></li> using their subscribe method: oMenu.hideEvent.subscribe(fnMyHandler);. YAHOO.widget.Menu:
<li><a href=” … ”>item two</a></li>
Methods
</ul> Key Menu Configuration Options
</div> See online docs for complete list of Menu options. addItem(o || s [,i])
</div> Option (type) Default Description addItems(o || s [,i])
Script: constrain true Forces a menu to remain inside the confines getItem(i [,i])
toviewport (b) of the viewport. getItems()
var oMenu = new YAHOO.widget.Menu("mymenu");
itemData (a) null Array of MenuItems to be added to Menu. getItemGroups()
oMenu.render(); getSubmenus()
oMenu.show(); lazyLoad (b) false Boolean value specifies whether Menu
should defer initialization and rendering of getRoot() returns root Menu
instance
Creates, renders and shows a menu using existing markup. submenus until needed. insertItem(o || s [,i] [,i])
position (s) "dynamic" Static: in the flow of the document, visible by removeItem(o || i [,i])
Constructor: YAHOO.widget.Menu (“static” for default. Dynamic: hidden by default, outside setItemGroupTitle(s [,i])
MenuBar) of page flow. show()
YAHOO.widget.Menu(str elId[, obj config]); submenuhidedelay 250 Delay (in ms) for hiding a submenu as a user hide()
(n) mouses out of parent MenuItem while clearContent()
Arguments: mousing toward the submenu. render([el])
(1) Element ID: HTML ID of the element being used to create the showdelay (n)/ 250 (show), Built-in delay when showing or hiding the destroy()
Menu. If this element doesn't exist, it will be created and hidedelay (n) 0 (hide) Menu, in miliseconds.
appended to the document body. trigger (s || o || a) Null The id(s) or node reference(s) for the
YAHOO.widget.
(2) Configuration Object: JS object defining configuration element(s) whose contextmenu event
properties for the Menu instance. See Configuration section for triggers the context menu's display. MenuItem: Properties
full list. maxheight (n) 0 The maximum height (in pixels) for a menu
element
before the contents of the body are scrolled.
parent
Menu options can be set in the constructor's second argument (eg, {visible: true}) or at
Three Types of Menus runtime via setProperty (eg, oMenu.cfg.setProperty("visible", false);).
id
groupIndex
index
Key MenuItem Configuration Options value
See online docs for complete list of MenuItem options.
Option (type) Default Description
checked (b) false Renders the item with a checkmark.
YAHOO.widget.
disabled (b) false If set to true the MenuItem will be MenuItem: Methods
dimmed and will not respond to user input
focus()
or fire events.
blur()
selected (b) false If set to true the MenuItem will be
highlighted.
submenu (o) null Appends a menu to the MenuItem.
Dependencies
target (s) null Value for the "target" attribute of the
item’s anchor element. Menu requires the
text (s) null Text label for the item. Container Core
url (s) "#" URL for the anchor's "href" attr.
package, the YAHOO
MenuItem options can be set in the constructor's second argument (eg, {disabled: true})
or at runtime via setProperty (eg, oMenuItem.cfg.setProperty("disabled", true);).
Object, Event, and
Dom.
YUI Library: Menu HTML & CSS Reference Guide 2008-2-19 v2.5

Vous aimerez peut-être aussi