We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3d4595c commit 92617ecCopy full SHA for 92617ec
1 file changed
select2.js
@@ -2236,7 +2236,21 @@ the specific language governing permissions and limitations under the Apache Lic
2236
return is_match;
2237
},
2238
callback: !$.isFunction(callback) ? $.noop : function() {
2239
- callback(matches);
+ // reorder matches based on the order they appear in the ids array because right now
2240
+ // they are in the order in which they appear in data array
2241
+ var ordered = [];
2242
+ for (var i = 0; i < ids.length; i++) {
2243
+ var id = ids[i];
2244
+ for (var j = 0; j < matches.length; j++) {
2245
+ var match = matches[j];
2246
+ if (equal(id, opts.id(match))) {
2247
+ ordered.push(match);
2248
+ matches.splice(j, 1);
2249
+ break;
2250
+ }
2251
2252
2253
+ callback(ordered);
2254
}
2255
});
2256
};
0 commit comments