JavaScript dropdown

Quick reference

Considering the example below:

<html>
<script src="https://jsuites.net/v4/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v4/jsuites.css" type="text/css" />

<div id="dropdown"></div>

<script>
var dropdown = jSuites.dropdown(document.getElementById('dropdown'), {
    url: '/v4/large',
    autocomplete: true,
    multiple: true,
    width: '280px',
});
</script>
</html>


Methods

Method Description
dropdown.open();Open the dropdown
dropdown.close(boolean);Close the dropdown
@param int ignoreEvents - Do no execute onclose event
dropdown.getText();Get the current label(s) from the selected option(s) in the dropdown
dropdown.getValue();Get the current value(s) from the selected option(s) in the dropdown
dropdown.setValue(string | array);Set a new value(s)
@param mixed newValue - A string value or an array with multiple values in case a multiple dropdown.
dropdown.reset();Clear all selected options from the dropdown
dropdown.add();Add a new element to the dropdown


Events

Method Description
onopenTrigger a method when the dropdown is opened.
(DOMElement element) => void
oncloseTrigger a method when the dropdown is closed.
(DOMElement element) => void
onchangeTrigger a method when value is changed.
(DOMElement element, Number index, String oldValue, String newValue, String oldLabel, String newLabel) => void
onfocusTrigger a method when the dropdown lost focus.
(DOMElement element, Number value) => void
onblurTrigger a method when the dropdown lost focus.
(DOMElement element, Number value) => void
oninsertTrigger a method when a new option is added to the dropdown.
(DOMElement element, Object item, Object dataItem) => void


Initialization options

Method Description
data: mixedData to load into the dropdown
src: stringCan be loaded from a external file
multiple: booleanMultiple options
autocomplete: booleanAllow autocomplete
type: stringRender type: default | picker | searchbar
width: numberDefault width
maxWidth: numberMax width for the dropdown
value: stringSelected value
placeholder: stringPlaceholder instructions
newOptions: booleanEnable the add new option controls