Print Friendly

Class YAHOO.ext.Button

Package:YAHOO.ext
Class:Button
Extends:Observable
Defined In:Button.js
Simple Button class

Config Options

Config Options Defined By
  handler : Function Button
A function called when the button is clicked (can be used instead of click event)
  minWidth : Number Button
The minimum width for this button (used to give a set of buttons a common width)
  scope : Object Button
The scope of the handler
  text : String Button
The button text

Public Properties

This class has no public properties.

Public Methods

Method Defined By
  Button(String/HTMLElement/Element renderTo, Object config) Button
Create a new button
  addListener(String eventName, Function handler, [Object scope], [boolean override]) : void Observable
Appends an event handler to this component
  bufferedListener(String eventName, Function handler, [Object scope], [Number millis]) : Function Observable
Appends an event handler to this component that is buffered. If the event is triggered more than once in the specifie...
  delayedListener(String eventName, Function handler, [Object scope], [Number delay]) : Function Observable
Appends an event handler to this component that is delayed the specified number of milliseconds. This is useful for e...
  disable() : void Button
Disable this button
  enable() : void Button
Enable this button
  fireEvent(String eventName, Object... args) : Boolean Observable
Fires the specified event with the passed parameters (minus the event name).
  focus() : void Button
Focus the button
  getEl() : YAHOO.ext.Element Button
Returns the buttons element
  hide() : void Button
Hide this button
  on(String eventName, Function handler, [Object scope], [boolean override]) : void Observable
Appends an event handler to this element (shorthand for addListener)
  purgeListeners() : void Observable
Removes all listeners for this object
  removeListener(String eventName, Function handler, [Object scope]) : void Observable
Removes a listener
  setHandler(Function handler, [Object scope]) : void Button
Sets this buttons click handler
  setText(String text) : void Button
Set this buttons text
  setVisible(Boolean visible) : void Button
Convenience function for boolean show/hide
  show() : void Button
Show this button

Public Events

Event Defined By
  click : (Button this, EventObject e) Button
Fires when this button is clicked

Config Details

handler

handler : Function
A function called when the button is clicked (can be used instead of click event)
This config option is defined by Button.

minWidth

minWidth : Number
The minimum width for this button (used to give a set of buttons a common width)
This config option is defined by Button.

scope

scope : Object
The scope of the handler
This config option is defined by Button.

text

text : String
The button text
This config option is defined by Button.

Constructor Details

Button

public function Button(String/HTMLElement/Element renderTo, Object config)
Create a new button
Parameters:
  • renderTo : String/HTMLElement/Element
    The element to append the button to
  • config : Object
    The config object

Method Details

addListener

public function addListener(String eventName, Function handler, [Object scope], [boolean override])
Appends an event handler to this component
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • override : boolean
    (optional) If true, scope becomes the scope
Returns:
  • void
This method is defined by Observable.

bufferedListener

public function bufferedListener(String eventName, Function handler, [Object scope], [Number millis])
Appends an event handler to this component that is buffered. If the event is triggered more than once in the specified time-frame, only the last one actually fires.
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • millis : Number
    (optional) The number of milliseconds to buffer (defaults to 250)
Returns:
  • Function
    The wrapped function that was created (can be used to remove the listener)
This method is defined by Observable.

delayedListener

public function delayedListener(String eventName, Function handler, [Object scope], [Number delay])
Appends an event handler to this component that is delayed the specified number of milliseconds. This is useful for events that modify the DOM and need to wait for the browser to catch up.
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • delay : Number
    (optional) The number of milliseconds to delay (defaults to 1 millisecond)
Returns:
  • Function
    The wrapped function that was created (can be used to remove the listener)
This method is defined by Observable.

disable

public function disable()
Disable this button
Parameters:
  • None.
Returns:
  • void
This method is defined by Button.

enable

public function enable()
Enable this button
Parameters:
  • None.
Returns:
  • void
This method is defined by Button.

fireEvent

public function fireEvent(String eventName, Object... args)
Fires the specified event with the passed parameters (minus the event name).
Parameters:
  • eventName : String
  • args : Object...
    Variable number of parameters are passed to handlers
Returns:
  • Boolean
    returns false if any of the handlers return false otherwise it returns true
This method is defined by Observable.

focus

public function focus()
Focus the button
Parameters:
  • None.
Returns:
  • void
This method is defined by Button.

getEl

public function getEl()
Returns the buttons element
Parameters:
  • None.
Returns:
  • YAHOO.ext.Element
This method is defined by Button.

hide

public function hide()
Hide this button
Parameters:
  • None.
Returns:
  • void
This method is defined by Button.

on

public function on(String eventName, Function handler, [Object scope], [boolean override])
Appends an event handler to this element (shorthand for addListener)
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope (this object) for the handler
  • override : boolean
    (optional) If true, scope becomes the scope
Returns:
  • void
This method is defined by Observable.

purgeListeners

public function purgeListeners()
Removes all listeners for this object
Parameters:
  • None.
Returns:
  • void
This method is defined by Observable.

removeListener

public function removeListener(String eventName, Function handler, [Object scope])
Removes a listener
Parameters:
  • eventName : String
    The type of event to listen for
  • handler : Function
    The handler to remove
  • scope : Object
    (optional) The scope (this object) for the handler
Returns:
  • void
This method is defined by Observable.

setHandler

public function setHandler(Function handler, [Object scope])
Sets this buttons click handler
Parameters:
  • handler : Function
    The function to call when the button is clicked
  • scope : Object
    (optional) Scope for the function passed above
Returns:
  • void
This method is defined by Button.

setText

public function setText(String text)
Set this buttons text
Parameters:
  • text : String
Returns:
  • void
This method is defined by Button.

setVisible

public function setVisible(Boolean visible)
Convenience function for boolean show/hide
Parameters:
  • visible : Boolean
    true to show/false to hide
Returns:
  • void
This method is defined by Button.

show

public function show()
Show this button
Parameters:
  • None.
Returns:
  • void
This method is defined by Button.

Event Details

click

public event click
Fires when this button is clicked
Subscribers will be called with the following parameters:
  • this : Button
  • e : EventObject
    The click event
This event is defined by Button.

yui-ext - Copyright © 2006 Jack Slocum. | Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.