new Dropdown(el, options, key) → {DropDown}
- Source:
Properties:
Name | Type | Description |
---|---|---|
options.updateText |
Boolean | should the dropdown text update to reflect the selected item |
options.interceptLinks |
Boolean | should any links called prevent default |
options.closeOnClick |
Boolean | should the dropdown close when an item is clicked |
Handles dropdowns
Example
Required markup:
html:
<div data-ui="Dropdown" data-ui-options='{"update-text": true, "intercept-links": true}' data-ui-key="downloads-dropdown">
<button data-dropdown-button>
<span class="mr-1" data-dropdown-text>View all products</span>
</button>
<div data-dropdown-menu>
<ul class="list-reset">
<li data-dropdown-reset role="button" tabindex="0">Reset</li>
<li>
<a data-dropdown-item>item</a>
</li>
<li>
<a data-dropdown-item>item</a>
</li>
<li>
<a data-dropdown-item>item</a>
</li>
</ul>
</div>
</div>
Parameters:
Name | Type | Description |
---|---|---|
el |
HTMLElement | node to bind to |
options |
Object | options |
key |
String | key name |
Returns:
- Type
- DropDown
Methods
(static) close() → {void}
- Source:
close the dropdown
Returns:
- Type
- void
(static) mount() → {void}
- Source:
removes the events
Returns:
- Type
- void
(static) mount() → {void}
- Source:
Add the events
Returns:
- Type
- void
(static) onBlur() → {void}
- Source:
the blur event... this is used to close the dropdown when clicking outside
Returns:
- Type
- void
(static) onClick(e) → {void}
- Source:
the click event...
Parameters:
Name | Type | Description |
---|---|---|
e |
Object | : the event object |
Returns:
- Type
- void
(static) onItemClick(e, elm) → {void}
- Source:
handle various options, this is only called when intercept links is true
Parameters:
Name | Type | Description |
---|---|---|
e |
Object | : the event object |
elm |
HTMLElement | : the element clicked |
Returns:
- Type
- void
(static) onResetClick(e) → {void}
- Source:
reset the dropdown label text and close
Parameters:
Name | Type | Description |
---|---|---|
e |
Object | : the event object |
Returns:
- Type
- void
(static) open() → {Promise}
- Source:
open the dropdown, once the animation has finished set the focus state
Returns:
- Type
- Promise