Permalink
Browse files

Better var names

  • Loading branch information...
1 parent 96443a8 commit fea825dfd2f68ce2704a41780721f6db9b3420bb @michaelperrin michaelperrin committed Oct 9, 2012
Showing with 5 additions and 5 deletions.
  1. +2 −2 lib/ajax-chosen.js
  2. +1 −1 lib/ajax-chosen.min.js
  3. +2 −2 src/ajax-chosen.coffee
View
4 lib/ajax-chosen.js
@@ -64,11 +64,11 @@
}
});
items = callback(data);
- $.each(items, function(value, element) {
+ $.each(items, function(i, element) {
var group;
if (element.group) {
group = $("<optgroup />").attr('label', element.text).appendTo(select);
- return $.each(element.items, function(value, element) {
+ return $.each(element.items, function(i, element) {
if ($.inArray(element.value + "-" + element.text, selected_values) === -1) {
return $("<option />").attr('value', element.value).html(element.text).appendTo(group);
}
View
2 lib/ajax-chosen.min.js
@@ -8,6 +8,6 @@ if(val.length<options.minTermLength){return false;}
field=$(this);if(!(options.data!=null)){options.data={};}
options.data[options.jsonTermKey]=val;if(options.dataCallback!=null){options.data=options.dataCallback(options.data);}
success=options.success;options.success=function(data){var items,selected_values;if(!(data!=null)){return;}
-selected_values=[];select.find('optgroup').each(function(){return $(this).remove();});select.find('option').each(function(){if(!$(this).is(":selected")){return $(this).remove();}else{return selected_values.push($(this).val()+"-"+$(this).text());}});items=callback(data);$.each(items,function(value,element){var group;if(element.group){group=$("<optgroup />").attr('label',element.text).appendTo(select);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){return $("<option />").attr('value',element.value).html(element.text).appendTo(select);}});select.trigger("liszt:updated");if(success!=null){success(data);}
+selected_values=[];select.find('optgroup').each(function(){return $(this).remove();});select.find('option').each(function(){if(!$(this).is(":selected")){return $(this).remove();}else{return selected_values.push($(this).val()+"-"+$(this).text());}});items=callback(data);$.each(items,function(i,element){var group;if(element.group){group=$("<optgroup />").attr('label',element.text).appendTo(select);return $.each(element.items,function(i,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){return $("<option />").attr('value',element.value).html(element.text).appendTo(select);}});select.trigger("liszt:updated");if(success!=null){success(data);}
return field.attr('value',untrimmed_val);};return this.timer=setTimeout(function(){if(chosenXhr){chosenXhr.abort();}
return chosenXhr=$.ajax(options);},options.afterTypeDelay);});});};})(jQuery);
View
4 src/ajax-chosen.coffee
@@ -93,12 +93,12 @@ do ($ = jQuery) ->
# Iterate through the given data and inject the <option> elements into
# the DOM if it doesn't exist in the selector already
- $.each items, (value, element) ->
+ $.each items, (i, element) ->
if element.group
group = $("<optgroup />")
.attr('label', element.text)
.appendTo(select)
- $.each element.items, (value, element) ->
+ $.each element.items, (i, element) ->
if $.inArray(element.value + "-" + element.text, selected_values) == -1
$("<option />")
.attr('value', element.value)

0 comments on commit fea825d

Please sign in to comment.