dianping/cat · error · Error
Option '{option}' is not allowed for Select2 when attached t
Error message
Option '{option}' is not allowed for Select2 when attached to a <select> element. What it means
Error "Option '{option}' is not allowed for Select2 when attached to a <select> element." thrown in dianping/cat.
Source
Thrown at cat-home/src/main/webapp/assets/js/uncompressed/select2.js:915
};
}
},
// abstract
prepareOpts: function (opts) {
var element, select, idKey, ajaxUrl, self = this;
element = opts.element;
if (element.get(0).tagName.toLowerCase() === "select") {
this.select = select = opts.element;
}
if (select) {
// these options are not allowed when attached to a select because they are picked up off the element itself
$.each(["id", "multiple", "ajax", "query", "createSearchChoice", "initSelection", "data", "tags"], function () {
if (this in opts) {
throw new Error("Option '" + this + "' is not allowed for Select2 when attached to a <select> element.");
}
});
}
opts = $.extend({}, {
populateResults: function(container, results, query) {
var populate, id=this.opts.id, liveRegion=this.liveRegion;
populate=function(results, container, depth) {
var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted;
results = opts.sortResults(results, container, query);
// collect the created nodes for bulk append
var nodes = [];
for (i = 0, l = results.length; i < l; i = i + 1) {
View on GitHub (pinned to e815e74d4c)
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.
When it happens
Trigger: 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>.
Common situations: See trigger scenarios.
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/5b1dbf987f860790.
Report an issue: GitHub.