new Dropdown(options) → {Class}
A dropdown component that can be used for simple stylized selects, more complex ones with simple fuzzy text search, or async dropdowns that get their data from rest or admin ajax.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for the component. Properties
|
- Since
- 1.1.16
The class instance.
- Type:
- Class
import Dropdown from '@gravityforms/components/html/admin/elements/Dropdown';
function Example() {
const dropdownInstance = new Dropdown( {
render: true,
renderTarget: '#example-target',
} );
}Members
(static) handleAsyncSearch
Handles hitting endpoints for lists data according to endpoint arguments passed in options.
- Since
- 1.1.16
(static) parseRestResponse
Handles applying the rest response items as dropdown items.
- Since
- 1.1.16
Methods
(static) bindEvents() → {void}
Binds all the events for the component.
- Since
- 1.1.16
- Type:
- void
(static) closeDropdown() → {void}
Modifies all needed classes that close the dropdown, and adjust state, plus also calling any callbacks.
- Since
- 1.1.16
- Type:
- void
(static) dropdownTemplate(options) → {string}
Generates the markup for a dropdown in the admin.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | The options for the component template. Properties
|
- Since
- 1.1.16
- Type:
- string
import { dropdownTemplate } from '@gravityforms/components/html/admin/elements/Dropdown';
function Example() {
const dropdownTemplateHTML = dropdownTemplate( options );
document.body.insertAdjacentHTML( 'beforeend', dropdownTemplateHTML );
}(static) handleA11y(e) → {void}
Handles accessibility for the dropdown.
| Name | Type | Description |
|---|---|---|
e |
- Since
- 1.1.16
- Type:
- void
(static) handleBasicSearch(e) → {void}
Does a basic text search on the dropdown items.
| Name | Type | Description |
|---|---|---|
e |
- Since
- 1.1.16
- Type:
- void
(static) handleChange(e) → {void}
Handles item selection in the dropdown list.
| Name | Type | Description |
|---|---|---|
e |
- Since
- 1.1.16
- Type:
- void
(static) handleControl() → {void}
Handles the control trigger being interacted with and either opens or closes the dropdown.
- Since
- 1.1.16
- Type:
- void
(static) handleMouseenter() → {void}
Opens the dropdown on the hover event.
- Since
- 1.1.16
- Type:
- void
(static) handleMouseleave() → {void}
Closes the dropdown on mouseleave if reveal type is hover.
- Since
- 1.1.16
- Type:
- void
(static) handlePosition() → {void}
If autoposition is true, automatically places the dropdown above or below the control based on the viewport.
- Since
- 1.1.16
- Type:
- void
(static) handleSearch(e) → {void}
Delegates search handling to either basic or async handlers based on search type in options.
| Name | Type | Description |
|---|---|---|
e |
- Since
- 1.1.16
- Type:
- void
(static) init() → {void}
Initialize the component.
- Since
- 1.1.16
- Type:
- void
(static) openDropdown() → {void}
Modifies all needed classes that open the dropdown, and adjust state, plus also calling any callbacks.
- Since
- 1.1.16
- Type:
- void
(static) render() → {void}
Renders the component into the dom.
- Since
- 1.1.16
- Type:
- void
(static) renderListData() → {void}
Renders the list data into the already rendered dropdown when called.
- Since
- 1.1.16
- Type:
- void
(static) setup() → {void}
Sets up various dom variables on init, like long title handling.
- Since
- 1.1.16
- Type:
- void
(static) storeTriggers() → {void}
Stores the dropdown triggers and reveal controls on the instance as HTMLElements.
- Since
- 1.1.16
- Type:
- void