src/selectivity.js
function(options) {
        options = options || {};

        var selectivity = this;
        Selectivity.OptionListeners.forEach(function(listener) {
            listener(selectivity, options);
        });

        if ('items' in options) {
            this.items = options.items ? Selectivity.processItems(options.items) : null;
        }
        if ('templates' in options) {
            assign(this.templates, options.templates);
        }

        assign(this.options, options);

        this.enabled = !this.options.readOnly && !this.options.removeOnly;
    }
function(options) {
        options = options || {};

        var selectivity = this;
        Selectivity.OptionListeners.forEach(function(listener) {
            listener(selectivity, options);
        });

        if ('items' in options) {
            this.items = options.items ? Selectivity.processItems(options.items) : null;
        }
        if ('templates' in options) {
            assign(this.templates, options.templates);
        }

        assign(this.options, options);

        this.enabled = !this.options.readOnly && !this.options.removeOnly;
    }
function ( options ) { options = options || { } ; var selectivity = this ; Selectivity . OptionListeners . forEach ( function ( listener ) { listener ( selectivity , options ) ; } ) ; if ( 'items' in options ) { this . items = options . items ? Selectivity . processItems ( options . items ) : null ; } if ( 'templates' in options ) { assign ( this . templates , options . templates ) ; } assign ( this . options , options ) ; this . enabled = ! this . options . readOnly && ! this . options . removeOnly ; }
Sets one or more options on this Selectivity instance.

@param options Options object. May contain one or more of the following properties:
closeOnSelect - Set to false to keep the dropdown open after the user has
selected an item. This is useful if you want to allow the user
to quickly select multiple items. The default value is true.
dropdown - Custom dropdown implementation to use for this instance.
initSelection - Function to map values by ID to selection data. This function
receives two arguments, 'value' and 'callback'. The value is
the current value of the selection, which is an ID or an array
of IDs depending on the input type. The callback should be
invoked with an object or array of objects, respectively,
containing 'id' and 'text' properties.
inputListeners - Array of search input listeners. By default, the global
array Selectivity.InputListeners is used.
items - Array of items from which to select. Should be an array of objects
with 'id' and 'text' properties. As convenience, you may also pass an
array of strings, in which case the same string is used for both the
'id' and 'text' properties. If items are given, all items are expected
to be available locally and all selection operations operate on this
local array only. If null, items are not available locally, and a
query function should be provided to fetch remote data.
matcher - Function to determine whether text matches a given search term. Note
this function is only used if you have specified an array of items.
Receives two arguments:
item - The item that should match the search term.
term - The search term. Note that for performance reasons, the term
has always been already processed using
Selectivity.transformText().
The method should return the item if it matches, and null otherwise.
If the item has a children array, the matcher is expected to filter
those itself (be sure to only return the filtered array of children
in the returned item and not to modify the children of the item
argument).
placeholder - Placeholder text to display when the element has no focus and
no selected items.
positionDropdown - Function to position the dropdown. Receives two arguments:
dropdownEl - The element to be positioned.
selectEl - The element of the Selectivity instance, that
you can position the dropdown to.
The default implementation positions the dropdown element
under the Selectivity's element and gives it the same
width.
query - Function to use for querying items. Receives a single object as
argument with the following properties:
callback - Callback to invoke when the results are available. This
callback should be passed a single object as argument with
the following properties:
more - Boolean that can be set to true to indicate there
are more results available. Additional results may
be fetched by the user through pagination.
results - Array of result items. The format for the result
items is the same as for passing local items.
offset - This property is only used for pagination and indicates how
many results should be skipped when returning more results.
selectivity - The Selectivity instance the query function is used on.
term - The search term the user is searching for. Unlike with the
matcher function, the term has not been processed using
Selectivity.transformText().
readOnly - If true, disables any modification of the input.
removeOnly - If true, disables any modification of the input except removing
of selected items.
shouldOpenSubmenu - Function to call that will decide whether a submenu should
be opened. Receives two parameters:
item - The currently highlighted result item.
reason - The reason why the item is being highlighted.
See Dropdown#highlight() for possible values.
showDropdown - Set to false if you don't want to use any dropdown (you can
still open it programmatically using open()).
showSearchInputInDropdown - Set to false to remove the search input used in
dropdowns. The default is true for single-value
inputs.
templates - Object with instance-specific templates to override the global
templates assigned to Selectivity.Templates.
Sets one or more options on this Selectivity instance .