Select2 - How to stop automatic sorting?
Looks like when using multiple, the items are sorted automatically.
Is there a way to stop this?
Live example here: http://plnkr.co/edit/5X7s8WZPVw7Z9gVWDjK3?p=preview
See also: http://stackoverflow.com/questions/14727502/angular-ui-select2-how-to-stop-automatic-sorting
I stumble upon the same issue, and after some test I'm thinking it's actually an issue in select2, and not in angular-ui.
When programmatically setting the select2 widget you can use select2.('val') or select2.('data'). As you can see here (http://jsfiddle.net/u7pYa/3/), select2.('val') does not preserve entry order, whereas select2.('data') does.
The select2 directive seems to use select2.('val') for multiple select. A fix could be to change that to select2.('data'), but I had no success with it so far...
It uses data if you pass an object instead of an idea. V0.4.0 may have some fixes. On Feb 6, 2013 8:06 AM, "Antoine BANCTEL-CHEVREL" [email protected] wrote:
I stumble upon the same issue, and after some test I'm thinking it's actually an issue in select2, and not in angular-ui.
When programmatically setting the select2 widget you can use select2.('val') or select2.('data'). As you can see here (http://jsfiddle.net/u7pYa/3/), select2.('val') does not preserve entry order, whereas select2.('data') does.
The select2 directive seems to use select2.('val') for multiple select. A fix could be to change that to select2.('data'), but I had no success with it so far...
— Reply to this email directly or view it on GitHubhttps://github.com/angular-ui/angular-ui/issues/406#issuecomment-13189174.
Where could I find the most updated code for 0.4.0? I can't see any branch or tag with 0.4.0.
I should probably start developing into a dedicated branch... Right now all v0.4.0 changes are in master.
@moroshko - https://github.com/angular-ui/angular-ui/blob/master/modules/directives/select2/select2.js
I have been poking around with this and it makes 0 sense why this should be occurring as angular and angularUI is not actually doing anything specifically to deal with data order. I will slate this fix for v0.4.1
AngularUI is currently undergoing a restructure. This project will no longer hold the codebase, can you please relocate this to https://github.com/angular-ui/ui-select2 (after confirming it's still necessary with the latest code)?
This repo is discontinued. The project has been relocated here: https://github.com/angular-ui/ui-select2
Please reopen this issue there if it is still relevant.
I have the same problem of Select2 4.0.0 I dont know how to disable sort when I select the items. anyone have any ideas ?
I solved this problem :)
$("select").select2({
tags: true });
$("select").on("select2:select", function (evt) { var element = evt.params.data.element; var $element = $(element);
$element.detach(); $(this).append($element); $(this).trigger("change"); });