new Alert(options) → {Class}
A alert component with 5 styles, default, notice, success, error and accessibility. It also allows for a cookie to store dismissed state.
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for the component. Properties
|
- Since
- 1.1.16
- Source
The class instance.
- Type:
- Class
import Alert from '@gravityforms/components/html/admin/elements/Alert';
function Example() {
const alertInstance = new Alert( {
content: 'This is an alert',
id: 'my-alert',
renderOnInit: false,
target: '#example-target',
targetPosition: 'beforeend',
type: 'error',
} );
// Some time later we can render it. This is only done if we set renderOnInit to false.
// If true it will render on initialization.
alertInstance.init();
}
Methods
(static) alertTemplate(options) → {string}
Generates the markup for an alert in the admin.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for the component template. Properties
|
- Since
- 1.1.16
- Source
- Type:
- string
import { alertTemplate } from '@gravityforms/components/html/admin/elements/Alert';
function Example() {
const alertTemplateHTML = alertTemplateTemplate( options );
document.body.insertAdjacentHTML( 'beforeend', alertTemplateHTML );
}
(static) bindEvents() → {void}
Bind event listeners for the alert.
- Since
- 1.1.16
- Source
- Type:
- void
(static) dismissAlert(e) → {void}
Dismiss the alert and store a cookie if name is set.
Name | Type | Description |
---|---|---|
e |
- 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