new Button(options) → {this}
A button component that returns an instance method and event api.
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options object for the class. Properties
|
- Since
- 1.0.5
- Source
- Type:
- this
import Button from '@gravityforms/components/html/admin/elements/Button';
function Example() {
const buttonInstance = new Button( {
id: 'example-button',
renderOnInit: false,
target: '#example-target',
targetPosition: 'beforeend',
theme: 'cosmos',
} );
// Some time later we can render it. This is only done if we set renderOnInit to false.
// If true it will render on initialization.
buttonInstance.init();
}
Methods
(static) activateButton() → {void}
If interactive, handles activating this button and swapping the ui state, plus executing any callbacks and firing useful events.
- Since
- 1.0.5
- Source
- Type:
- void
(static) bindEvents() → {void}
Bind event handles for the button instance.
- Since
- 1.1.16
- Source
- Type:
- void
(static) buttonTemplate(options) → {string}
The template function used to generate our button html.
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options object for the class. Properties
|
- Since
- 1.0.5
- Source
The button html.
- Type:
- string
import { buttonTemplate } from '@gravityforms/components/html/admin/elements/Button';
function Example() {
const buttonHTML = buttonTemplate( options );
document.body.insertAdjacentHTML( 'beforeend', buttonHTML );
}
(static) deactivateButton() → {void}
If interactive, handles deactivating this button and swapping the ui state, plus executing any callbacks and firing useful events.
- Since
- 1.0.5
- Source
- Type:
- void
(static) handleButtonClick() → {void}
If interactive and button is not active, activate it.
- Since
- 1.1.16
- Source
- Type:
- void
(static) init() → {void}
Initialize the component.
- Since
- 1.1.16
- Source
- Type:
- void
(static) render() → {void}
Renders the component into the dom.
- Since
- 1.1.16
- Source
- Type:
- void
(static) renderInteractive() → {void}
If interactive render the elements that are present on active state.
- Since
- 1.1.16
- Source
- Type:
- void
(static) storeElements() → {void}
Stores useful HTMLElements on the instance in the elements namespace after render
- Since
- 1.1.16
- Source
- Type:
- void