dianping/cat · error · Error
Sorting of elements is not supported when attached to <selec
Error message
Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.
What it means
Error "Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead." thrown in dianping/cat.
Source
Thrown at cat-home/src/main/webapp/assets/js/uncompressed/select2.js:3278
}
this.opts.initSelection(this.opts.element, function(data){
var ids=$.map(data, self.id);
self.setVal(ids);
self.updateSelection(data);
self.clearSearch();
if (triggerChange) {
self.triggerChange(self.buildChangeDetails(oldData, self.data()));
}
});
}
this.clearSearch();
},
// multi
onSortStart: function() {
if (this.select) {
throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");
}
// collapse search field into 0 width so its container can be collapsed as well
this.search.width(0);
// hide the container
this.searchContainer.hide();
},
// multi
onSortEnd:function() {
var val=[], self=this;
// show search and move it to the end of the list
this.searchContainer.show();
// make sure the search container is the last item in the list
this.searchContainer.appendTo(this.searchContainer.parent());
// since we collapsed the width in dragStarted, we resize it hereView on GitHub (pinned to e815e74d4c)
Solutions
- Attach Select2 to an <input type='hidden'/> element to enable drag-and-drop sorting of selections.
- Disable the sortable behavior when the control is bound to a <select>.
When it happens
Trigger: Triggered when Select2 sorting (sortResults / ordering of selected elements) is used while attached to a <select> element instead of an <input type='hidden'>.
Common situations: See trigger scenarios.
AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14).
Data as JSON: /api/errors/0404141dfe3a8c38.
Report an issue: GitHub.