Categories

.button()

Categories: UI

.button( [ options ] )

Plugin: jQuery.ui.button

Description: Apply the Button widget for each element in the set of matched elements

  • .button( [ options ] )

    version added: 1.0

    options   A map of additional options pass to the widget.

Button enhances standard form elements like button, input of type submit or reset or anchors to themable buttons with appropiate mouseover and active styles.

In addition to basic push buttons, radio buttons and checkboxes (inputs of type radio and checkbox) can be converted to buttons: Their associated label is styled to appear as the button, while the underlying input is updated on click.

In order to group radio buttons, Button also provides an additional widget-method, called Buttonset. Its used by selecting a container element (which contains the radio buttons) and calling buttonset(). Buttonset will also provide visual grouping, and therefore should be used whenever you have a group of buttons. It works by selecting all descendents and applying button() to them. You can enable and disable a buttonset, which will enable and disable all contained buttons. Destroying a buttonset also calls the button's destroy method.

When using an input of type button, submit or reset, support is limited to plain text labels with no icons.

  • disabled

    Disables (true) or enables (false) the button. Can be set when initialising (first creating) the button.

    Default: false

  • text

    Whether to show any text - when set to false (display no text), icons (see icons option) must be enabled, otherwise it'll be ignored.

    Default: true

  • icons

    Icons to display, with or without text (see text option). The primary icon is displayed by default on the left of the label text, the secondary by default is on the right. Value for the primary and secondary properties must be a classname (String), eg. "ui-icon-gear". For using only one icon: icons: {primary:'ui-icon-locked'}. For using two icons: icons: {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'}

    Default: { primary: null, secondary: null }

  • label

    Text to show on the button. When not specified (null), the element's html content is used, or its value attribute when it's an input element of type submit or reset; or the html content of the associated label element if its an input of type radio or checkbox

    Default: HTML content of the button, or value attribute

  • create

    This event is triggered when button is created.

  • destroy

    • .button( "destroy" )

      version added: 1.0

    Remove the button functionality completely. This will return the element back to its pre-init state.

  • disable

    • .button( "disable" )

      version added: 1.0

    Disable the button.

  • enable

    • .button( "enable" )

      version added: 1.0

    Enable the button.

  • option

    • .button( "option" , optionName , [value] )

      version added: 1.0

    Get or set any button option. If no value is specified, will act as a getter.

  • option

    • .button( "option" , options )

      version added: 1.0

    Set multiple button options at once by providing an options object.

  • widget

    • .button( "widget" )

      version added: 1.0

    Returns the .ui-button element.

  • refresh

    • .button( "refresh" )

      version added: 1.0

    Refreshes the visual state of the button. Useful for updating button state after the native element's checked or disabled state is changed programatically.