src/inputs/multiple.js
function(item) {
        var itemIsId = Selectivity.isValidId(item);
        var id = itemIsId ? item : this.validateItem(item) && item.id;

        if (this.options.allowDuplicates || this._value.indexOf(id) === -1) {
            this._value.push(id);

            if (itemIsId && this.options.initSelection) {
                this.options.initSelection(
                    [id],
                    function(data) {
                        if (this._value.indexOf(id) > -1) {
                            item = this.validateItem(data[0]);
                            this._data.push(item);

                            this.triggerChange({ added: item });
                        }
                    }.bind(this)
                );
            } else {
                if (itemIsId) {
                    item = this.getItemForId(id);
                }
                this._data.push(item);

                this.triggerChange({ added: item });
            }
        }

        this.input.value = '';
        this._updateInputWidth();
    }
function(item) {
        var itemIsId = Selectivity.isValidId(item);
        var id = itemIsId ? item : this.validateItem(item) && item.id;

        if (this.options.allowDuplicates || this._value.indexOf(id) === -1) {
            this._value.push(id);

            if (itemIsId && this.options.initSelection) {
                this.options.initSelection(
                    [id],
                    function(data) {
                        if (this._value.indexOf(id) > -1) {
                            item = this.validateItem(data[0]);
                            this._data.push(item);

                            this.triggerChange({ added: item });
                        }
                    }.bind(this)
                );
            } else {
                if (itemIsId) {
                    item = this.getItemForId(id);
                }
                this._data.push(item);

                this.triggerChange({ added: item });
            }
        }

        this.input.value = '';
        this._updateInputWidth();
    }
function ( item ) { var itemIsId = Selectivity . isValidId ( item ) ; var id = itemIsId ? item : this . validateItem ( item ) && item . id ; if ( this . options . allowDuplicates || this . _value . indexOf ( id ) === - 1 ) { this . _value . push ( id ) ; if ( itemIsId && this . options . initSelection ) { this . options . initSelection ( [ id ] , function ( data ) { if ( this . _value . indexOf ( id ) > - 1 ) { item = this . validateItem ( data [ 0 ] ) ; this . _data . push ( item ) ; this . triggerChange ( { added : item } ) ; } } . bind ( this ) ) ; } else { if ( itemIsId ) { item = this . getItemForId ( id ) ; } this . _data . push ( item ) ; this . triggerChange ( { added : item } ) ; } } this . input . value = '' ; this . _updateInputWidth ( ) ; }
Adds an item to the selection, if it's not selected yet.

@param item The item to add. May be an item with 'id' and 'text' properties or just an ID.
Adds an item to the selection if it s not selected yet .