{"record":{"id":"0404141dfe3a8c38","repo":"dianping/cat","slug":"sorting-of-elements-is-not-supported-when-attached","errorCode":null,"errorMessage":"Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.","messagePattern":"Sorting of elements is not supported when attached to <select>\\. Attach to <input type='hidden'/> instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/select2.js","lineNumber":3278,"sourceCode":"                }\n\n                this.opts.initSelection(this.opts.element, function(data){\n                    var ids=$.map(data, self.id);\n                    self.setVal(ids);\n                    self.updateSelection(data);\n                    self.clearSearch();\n                    if (triggerChange) {\n                        self.triggerChange(self.buildChangeDetails(oldData, self.data()));\n                    }\n                });\n            }\n            this.clearSearch();\n        },\n\n        // multi\n        onSortStart: function() {\n            if (this.select) {\n                throw new Error(\"Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.\");\n            }\n\n            // collapse search field into 0 width so its container can be collapsed as well\n            this.search.width(0);\n            // hide the container\n            this.searchContainer.hide();\n        },\n\n        // multi\n        onSortEnd:function() {\n\n            var val=[], self=this;\n\n            // show search and move it to the end of the list\n            this.searchContainer.show();\n            // make sure the search container is the last item in the list\n            this.searchContainer.appendTo(this.searchContainer.parent());\n            // since we collapsed the width in dragStarted, we resize it here","sourceCodeStart":3260,"sourceCodeEnd":3296,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/select2.js#L3260-L3296","documentation":"Error \"Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.\" thrown in dianping/cat.","triggerScenarios":"Triggered when Select2 sorting (sortResults / ordering of selected elements) is used while attached to a <select> element instead of an <input type='hidden'>.","commonSituations":"See trigger scenarios.","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>."],"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"}