JavaScript enhancements for the Button component

Preserve

Hierarchy

  • GOVUKFrontendComponent
    • Button

Constructors

  • Parameters

    • $module: Element

      HTML element to use for button

    • Optional config: ButtonConfig = {}

      Button config

    Returns Button

Properties

$module: HTMLElement
config: ButtonConfig
debounceFormSubmitTimer: number = null
defaults: ButtonConfig = ...

Button default config

See

ButtonConfig

Constant

moduleName: string = 'govuk-button'

Name for the component used when initialising using data-module attributes.

schema: Readonly<{
    properties: {
        preventDoubleClick: {
            type: "boolean";
        };
    };
}> = ...

Button config schema

Type declaration

  • properties: {
        preventDoubleClick: {
            type: "boolean";
        };
    }
    • preventDoubleClick: {
          type: "boolean";
      }
      • type: "boolean"

Constant

Methods

  • Private

    Debounce double-clicks

    If the click quickly succeeds a previous click then nothing will happen. This stops people accidentally causing multiple form submissions by double clicking buttons.

    Parameters

    • event: MouseEvent

      Mouse click event

    Returns false

    Returns undefined, or false when debounced