{"record":{"id":"5b1dbf987f860790","repo":"dianping/cat","slug":"option-option-is-not-allowed-for-select2-when","errorCode":null,"errorMessage":"Option '{option}' is not allowed for Select2 when attached to a <select> element.","messagePattern":"Option '(.+?)' is not allowed for Select2 when attached to a <select> element\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/select2.js","lineNumber":915,"sourceCode":"                };\n            }\n        },\n\n        // abstract\n        prepareOpts: function (opts) {\n            var element, select, idKey, ajaxUrl, self = this;\n\n            element = opts.element;\n\n            if (element.get(0).tagName.toLowerCase() === \"select\") {\n                this.select = select = opts.element;\n            }\n\n            if (select) {\n                // these options are not allowed when attached to a select because they are picked up off the element itself\n                $.each([\"id\", \"multiple\", \"ajax\", \"query\", \"createSearchChoice\", \"initSelection\", \"data\", \"tags\"], function () {\n                    if (this in opts) {\n                        throw new Error(\"Option '\" + this + \"' is not allowed for Select2 when attached to a <select> element.\");\n                    }\n                });\n            }\n\n            opts = $.extend({}, {\n                populateResults: function(container, results, query) {\n                    var populate, id=this.opts.id, liveRegion=this.liveRegion;\n\n                    populate=function(results, container, depth) {\n\n                        var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted;\n\n                        results = opts.sortResults(results, container, query);\n\n                        // collect the created nodes for bulk append\n                        var nodes = [];\n                        for (i = 0, l = results.length; i < l; i = i + 1) {\n","sourceCodeStart":897,"sourceCodeEnd":933,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/select2.js#L897-L933","documentation":"Error \"Option '{option}' is not allowed for Select2 when attached to a <select> element.\" thrown in dianping/cat.","triggerScenarios":"Triggered when Select2 is initialized on a <select> element with an option (such as 'tags' or custom data) that is only valid on a hidden <input>.","commonSituations":"See trigger scenarios.","solutions":["Remove the option that is incompatible with <select>-backed Select2 (e.g. data, query, createSearchChoice).","Attach Select2 to an <input type='hidden'/> if those options are needed."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}