YUI recommends YUI 3.

YUI 2 has been deprecated since 2011. This site acts as an archive for files and documentation.

Yahoo! UI Library

Button  2.2.0

Yahoo! UI Library > button > YAHOO.widget.ButtonGroup

Class YAHOO.widget.ButtonGroup - extends YAHOO.util.Element

The ButtonGroup class creates a set of buttons that are mutually exclusive; checking one button in the set will uncheck all others in the button group.

Constructor

YAHOO.widget.ButtonGroup ( p_oElement , p_oAttributes )
Parameters:
p_oElement <String> String specifying the id attribute of the <div> element of the button group.
p_oElement <HTMLDivElement> Object specifying the <div> element of the button group.
p_oElement <Object> Object literal specifying a set of configuration attributes used to create the button group.
p_oAttributes <Object> Optional. Object literal specifying a set of configuration attributes used to create the button group.

Properties

_buttons - protected Array

Array of buttons in the button group.
Default Value: null

_oninitAttributeValue - protected Object

Object reference to the button group's current value for the "oninit" configuration attribute.
Default Value: null

CSS_CLASS_NAME - final String

String representing the CSS class(es) to be applied to the button group's element.
Default Value: "yuibuttongroup"

TAG_NAME - final String

The name of the tag to be used for the button group's element.
Default Value: "DIV"

Properties inherited from YAHOO.util.Element:

Properties inherited from YAHOO.util.AttributeProvider:

Methods

_createGroupElement

protected HTMLDivElement _createGroupElement ( )
Creates the button group's element.
Returns: HTMLDivElement

_onAppendTo

protected void _onAppendTo ( p_oEvent )
"appendTo" event handler for the button group.
Parameters:
p_oEvent <Event> Object representing the event that was fired.
Returns: void

_onButtonCheckedChange

protected void _onButtonCheckedChange ( p_oEvent , p_oButton )
"checkedChange" event handler for each button in the button group.
Parameters:
p_oEvent <Event> Object representing the event that was fired.
p_oButton <YAHOO.widget.Button> Object representing the button that fired the event.
Returns: void

_onKeyDown

protected void _onKeyDown ( p_oEvent )
"keydown" event handler for the button group.
Parameters:
p_oEvent <Event> Object representing the DOM event object passed back by the event utility (YAHOO.util.Event).
Returns: void

_setDisabled

protected void _setDisabled ( p_bDisabled )
Sets the value of the button groups's "disabled" attribute.
Parameters:
p_bDisabled <Boolean> Boolean indicating the value for the button group's "disabled" attribute.
Returns: void

_setOnInit

protected void _setOnInit ( p_oObject )
Sets the value of the button group's "init" attribute.
Parameters:
p_oObject <Object> Object indicating the value for the button's "oninit" attribute.
Returns: void

addButton

YAHOO.widget.Button addButton ( p_oButton )
Adds the button to the button group.
Parameters:
p_oButton <YAHOO.widget.Button> Object reference for the YAHOO.widget.Button instance to be added to the button group.
p_oButton <String> String specifying the id attribute of the <input> or <span> element to be used to create the button to be added to the button group.
p_oButton <HTMLInputElement|HTMLElement> Object reference for the <input> or <span> element to be used to create the button to be added to the button group.
p_oButton <Object> Object literal specifying a set of YAHOO.widget.Button configuration attributes used to configure the button to be added to the button group.
Returns: YAHOO.widget.Button

addButtons

Array addButtons ( p_aButtons )
Adds the array of buttons to the button group.
Parameters:
p_aButtons <Array> Array of YAHOO.widget.Button instances to be added to the button group.
p_aButtons <Array> Array of strings specifying the id attribute of the <input> or <span> elements to be used to create the buttons to be added to the button group.
p_aButtons <Array> Array of object references for the <input> or <span> elements to be used to create the buttons to be added to the button group.
p_aButtons <Array> Array of object literals, each containing a set of YAHOO.widget.Button configuration attributes used to configure each button to be added to the button group.
Returns: Array

check

void check ( p_nIndex )
Checks the button at the specified index.
Parameters:
p_nIndex <Number> Number indicating the index of the button to check.
Returns: void

destroy

void destroy ( )
Removes the button group's element from its parent element and removes all event handlers.
Returns: void

focus

void focus ( p_nIndex )
Sets focus to the button at the specified index.
Parameters:
p_nIndex <Number> Number indicating the index of the button to focus.
Returns: void

getButton

YAHOO.widget.Button getButton ( p_nIndex )
Returns the button at the specified index.
Parameters:
p_nIndex <Number> The index of the button to retrieve from the button group.
Returns: YAHOO.widget.Button

getButtons

Array getButtons ( )
Returns an array of the buttons in the button group.
Returns: Array

getCount

Number getCount ( )
Returns the number of buttons in the button group.
Returns: Number

init

void init ( p_oElement , p_oAttributes )
The ButtonGroup class's initialization method.
Parameters:
p_oElement <String> String specifying the id attribute of the <div> element of the button group.
p_oElement <HTMLDivElement> Object specifying the <div> element of the button group.
p_oElement <Object> Object literal specifying a set of configuration attributes used to create the button group.
p_oAttributes <Object> Optional. Object literal specifying a set of configuration attributes used to create the button group.
Returns: void

initAttributes

void initAttributes ( p_oAttributes )
Initializes all of the configuration attributes used to create the button group.
Parameters:
p_oAttributes <Object> Object literal specifying a set of configuration attributes used to create the button group.
Returns: void

removeButton

void removeButton ( p_nIndex )
Removes the button at the specified index from the button group.
Parameters:
p_nIndex <Number> Number specifying the index of the button to be removed from the button group.
Returns: void

toString

String toString ( )
Returns a string representing the button group.
Returns: String

Events

init

init ( )
Fires when the button group is initialized. Subscribe to this event by specifying a value for the "oninit" configuration attribute. Format:
{
fn: Function, // The handler to call when the event fires.
obj: Object, // An object to pass back to the handler.
scope: Object // The object to use for the scope of the handler.
}

Events inherited from YAHOO.util.Element:

Configuration Attributes

checkedButton - {YAHOO.widget.Button}

Reference for the button in the button group that is checked.
Default Value: null

container - HTMLElement|String

HTML element reference or string specifying the id attribute of the HTML element that the button group's markup should be rendered into.
Default Value: null

disabled - Boolean

Boolean indicating if the button group should be disabled. Disabling the button group will disable each button in the button group. Disabled buttons are dimmed and will not respond to user input or fire events.
Default Value: false

name - String

String specifying the name for the button group. This name will be applied to each button in the button group.
Default Value: null

oninit - Object

Object literal representing the code to be executed when the button group is initialized. Format:
{
fn: Function, // The handler to call when the event fires.
obj: Object, // An object to pass back to the handler.
scope: Object // The object to use for the scope of the handler.
}
Default Value: null

value - Object

Object specifying the value for the button group.
Default Value: null

Configuration attributes inherited from YAHOO.util.Element:


Copyright © 2007 Yahoo! Inc. All rights reserved.