Browse files

Grouping keeps order (breaks compatibility)

  • Loading branch information...
1 parent a0bbf08 commit d9ec8c85c793a2d3fc49879bf339aa1f834fede9 @michaelperrin michaelperrin committed Oct 9, 2012
Showing with 7 additions and 7 deletions.
  1. +3 −3 lib/ajax-chosen.js
  2. +4 −4 src/ajax-chosen.coffee
View
6 lib/ajax-chosen.js
@@ -68,9 +68,9 @@
var group;
if (element.group) {
group = $("<optgroup />").attr('label', element.text).appendTo(select);
- return $.each(element.items, function(value, text) {
- if ($.inArray(value + "-" + text, selected_values) === -1) {
- return $("<option />").attr('value', value).html(text).appendTo(group);
+ return $.each(element.items, function(value, element) {
+ if ($.inArray(element.value + "-" + element.text, selected_values) === -1) {
+ return $("<option />").attr('value', element.value).html(element.text).appendTo(group);
}
});
} else if ($.inArray(element.value + "-" + element.text, selected_values) === -1) {
View
8 src/ajax-chosen.coffee
@@ -98,11 +98,11 @@ do ($ = jQuery) ->
group = $("<optgroup />")
.attr('label', element.text)
.appendTo(select)
- $.each element.items, (value, text) ->
- if $.inArray(value + "-" + text, selected_values) == -1
+ $.each element.items, (value, element) ->
+ if $.inArray(element.value + "-" + element.text, selected_values) == -1
$("<option />")
- .attr('value', value)
- .html(text)
+ .attr('value', element.value)
+ .html(element.text)
.appendTo(group)
else if $.inArray(element.value + "-" + element.text, selected_values) == -1
$("<option />")

0 comments on commit d9ec8c8

Please sign in to comment.