Option name | Type | Description |
---|---|---|
selector | domelement_or_querystring_or_jqueryobject | either empty (for select element mirroring), or containing ".js-options"/".options" with the dropdown choices, and ".js-current"/".current" to display the active option. If a scrollbar is desired, it should also contain ".js-scrollable"/".scrollable", ".js-scrollbar"/".scrollbar", ".js-track"/".track", and ".js-handle"/".handle" |
options | object | Object containing the settings for this dropdown |
NATION.Utils
NATION.EventDispatcher
Optionally NATION.VerticalScrollbar if you want a scrollbar
JavaScript downdown menu with optional scrollbar (via NATION.VerticalScrollbar)
There are two ways this class can work:
If you want to use HTML other than the default, you'll need to either define a template inside your selector (if not mirroring a select field), or define one in a JavaScript template tag, and reference it by ID.
If you're not mirroring a select field, the only tag that needs to be in your HTML is {{defaultOption}}, which should be inside the .js-current element. This is where the code will insert the currently selected option text
If you ARE mirroring a select field, your template needs a few more tags in addition:
Event that fies when a new option is selected by the user
Event that fires when an option is selected by the user that is already selected
Event that fires when the dropdown opens
Event that fires when the dropdown closes
Returns the currently selected option's value
Returns the visible text for the currently selected option
Returns the zero-indexed ID of the currently selected option
Returns whether the dropdown is open or not
Opens the dropdown pane
Closes the dropdown pane
Option name | Type | Description |
---|---|---|
index | number | The zero-indexed ID for the option that should be marked as selected |
Select the option specified by 'index' and show it as active