public/javascript/libs/select2.js
function (data, options) {

            if (!this.triggerSelect(data)) { return; }

            this.addSelectedChoice(data);

            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });

            if (this.select || !this.opts.closeOnSelect) this.postprocessResults();

            if (this.opts.closeOnSelect) {
                this.close();
                this.search.width(10);
            } else {
                if (this.countSelectableResults()>0) {
                    this.search.width(10);
                    this.resizeSearch();
                    if (this.getMaximumSelectionSize() > 0 && this.val().length >= this.getMaximumSelectionSize()) {
                        // if we reached max selection size repaint the results so choices
                        // are replaced with the max selection reached message
                        this.updateResults(true);
                    }
                    this.positionDropdown();
                } else {
                    // if nothing left to select close
                    this.close();
                    this.search.width(10);
                }
            }

            // since its not possible to select an element that has already been
            // added we do not need to check if this is a new element before firing change
            this.triggerChange({ added: data });

            if (!options || !options.noFocus)
                this.focusSearch();
        }
function (data, options) {

            if (!this.triggerSelect(data)) { return; }

            this.addSelectedChoice(data);

            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });

            if (this.select || !this.opts.closeOnSelect) this.postprocessResults();

            if (this.opts.closeOnSelect) {
                this.close();
                this.search.width(10);
            } else {
                if (this.countSelectableResults()>0) {
                    this.search.width(10);
                    this.resizeSearch();
                    if (this.getMaximumSelectionSize() > 0 && this.val().length >= this.getMaximumSelectionSize()) {
                        // if we reached max selection size repaint the results so choices
                        // are replaced with the max selection reached message
                        this.updateResults(true);
                    }
                    this.positionDropdown();
                } else {
                    // if nothing left to select close
                    this.close();
                    this.search.width(10);
                }
            }

            // since its not possible to select an element that has already been
            // added we do not need to check if this is a new element before firing change
            this.triggerChange({ added: data });

            if (!options || !options.noFocus)
                this.focusSearch();
        }
function ( data , options ) { if ( ! this . triggerSelect ( data ) ) { return ; } this . addSelectedChoice ( data ) ; this . opts . element . trigger ( { type : "selected" , val : this . id ( data ) , choice : data } ) ; if ( this . select || ! this . opts . closeOnSelect ) this . postprocessResults ( ) ; if ( this . opts . closeOnSelect ) { this . close ( ) ; this . search . width ( 10 ) ; } else { if ( this . countSelectableResults ( ) > 0 ) { this . search . width ( 10 ) ; this . resizeSearch ( ) ; if ( this . getMaximumSelectionSize ( ) > 0 && this . val ( ) . length >= this . getMaximumSelectionSize ( ) ) { // if we reached max selection size repaint the results so choices // are replaced with the max selection reached message this . updateResults ( true ) ; } this . positionDropdown ( ) ; } else { // if nothing left to select close this . close ( ) ; this . search . width ( 10 ) ; } } // since its not possible to select an element that has already been // added we do not need to check if this is a new element before firing change this . triggerChange ( { added : data } ) ; if ( ! options || ! options . noFocus ) this . focusSearch ( ) ; }
multi
multi