public/javascript/libs/select2.js
function () {
            var opts = this.parent.prepareOpts.apply(this, arguments),
                self=this;

            if (opts.element.get(0).tagName.toLowerCase() === "select") {
                // install the selection initializer
                opts.initSelection = function (element, callback) {
                    var selected = element.find(":selected");
                    // a single select box always has a value, no need to null check 'selected'
                    callback(self.optionToData(selected));
                };
            } else if ("data" in opts) {
                // install default initSelection when applied to hidden input and data is local
                opts.initSelection = opts.initSelection || function (element, callback) {
                    var id = element.val();
                    //search in data by id, storing the actual matching item
                    var match = null;
                    opts.query({
                        matcher: function(term, text, el){
                            var is_match = equal(id, opts.id(el));
                            if (is_match) {
                                match = el;
                            }
                            return is_match;
                        },
                        callback: !$.isFunction(callback) ? $.noop : function() {
                            callback(match);
                        }
                    });
                };
            }

            return opts;
        }
function () {
            var opts = this.parent.prepareOpts.apply(this, arguments),
                self=this;

            if (opts.element.get(0).tagName.toLowerCase() === "select") {
                // install the selection initializer
                opts.initSelection = function (element, callback) {
                    var selected = element.find(":selected");
                    // a single select box always has a value, no need to null check 'selected'
                    callback(self.optionToData(selected));
                };
            } else if ("data" in opts) {
                // install default initSelection when applied to hidden input and data is local
                opts.initSelection = opts.initSelection || function (element, callback) {
                    var id = element.val();
                    //search in data by id, storing the actual matching item
                    var match = null;
                    opts.query({
                        matcher: function(term, text, el){
                            var is_match = equal(id, opts.id(el));
                            if (is_match) {
                                match = el;
                            }
                            return is_match;
                        },
                        callback: !$.isFunction(callback) ? $.noop : function() {
                            callback(match);
                        }
                    });
                };
            }

            return opts;
        }
function ( ) { var opts = this . parent . prepareOpts . apply ( this , arguments ) , self = this ; if ( opts . element . get ( 0 ) . tagName . toLowerCase ( ) === "select" ) { // install the selection initializer opts . initSelection = function ( element , callback ) { var selected = element . find ( ":selected" ) ; // a single select box always has a value, no need to null check 'selected' callback ( self . optionToData ( selected ) ) ; } ; } else if ( "data" in opts ) { // install default initSelection when applied to hidden input and data is local opts . initSelection = opts . initSelection || function ( element , callback ) { var id = element . val ( ) ; //search in data by id, storing the actual matching item var match = null ; opts . query ( { matcher : function ( term , text , el ) { var is_match = equal ( id , opts . id ( el ) ) ; if ( is_match ) { match = el ; } return is_match ; } , callback : ! $ . isFunction ( callback ) ? $ . noop : function ( ) { callback ( match ) ; } } ) ; } ; } return opts ; }
single
single