Skip to content
This repository
Browse code

Oops, jquery's `is` and `not` are not related, my bad

  • Loading branch information...
commit 63a7728e5a52d746078b7a6face80f9116a16138 1 parent 5595836
Fred Wu authored February 08, 2013
2  lib/ajax-chosen.js
@@ -53,7 +53,7 @@
53 53
           }
54 54
           selected_values = [];
55 55
           select.find('option').each(function() {
56  
-            if ($(this).not(":selected")) {
  56
+            if (!$(this).is(":selected")) {
57 57
               return $(this).remove();
58 58
             } else {
59 59
               return selected_values.push($(this).val() + "-" + $(this).text());
2  lib/ajax-chosen.min.js
@@ -7,7 +7,7 @@ if(val.length<options.minTermLength){return false;}
7 7
 field=$(this);if(options.data==null){options.data={};}
8 8
 options.data[options.jsonTermKey]=val;if(options.dataCallback!=null){options.data=options.dataCallback(options.data);}
9 9
 success=options.success;options.success=function(data){var items,nbItems,selected_values;if(data==null){return;}
10  
-selected_values=[];select.find('option').each(function(){if($(this).not(":selected")){return $(this).remove();}else{return selected_values.push($(this).val()+"-"+$(this).text());}});select.find('optgroup:empty').each(function(){return $(this).remove();});items=callback!=null?callback(data,field):data;nbItems=0;$.each(items,function(i,element){var group,text,value;nbItems++;if(element.group){group=select.find("optgroup[label='"+element.text+"']");if(!group.size()){group=$("<optgroup />");}
  10
+selected_values=[];select.find('option').each(function(){if(!$(this).is(":selected")){return $(this).remove();}else{return selected_values.push($(this).val()+"-"+$(this).text());}});select.find('optgroup:empty').each(function(){return $(this).remove();});items=callback!=null?callback(data,field):data;nbItems=0;$.each(items,function(i,element){var group,text,value;nbItems++;if(element.group){group=select.find("optgroup[label='"+element.text+"']");if(!group.size()){group=$("<optgroup />");}
11 11
 group.attr('label',element.text).appendTo(select);return $.each(element.items,function(i,element){var text,value;if(typeof element==="string"){value=i;text=element;}else{value=element.value;text=element.text;}
12 12
 if($.inArray(value+"-"+text,selected_values)===-1){return $("<option />").attr('value',value).html(text).appendTo(group);}});}else{if(typeof element==="string"){value=i;text=element;}else{value=element.value;text=element.text;}
13 13
 if($.inArray(value+"-"+text,selected_values)===-1){return $("<option />").attr('value',value).html(text).appendTo(select);}}});if(nbItems){select.trigger("liszt:updated");}else{select.data().chosen.no_results_clear();select.data().chosen.no_results(field.val());}
2  src/ajax-chosen.coffee
@@ -81,7 +81,7 @@ do ($ = jQuery) ->
81 81
             # by the user, add them to a list to filter from the results later.
82 82
             selected_values = []
83 83
             select.find('option').each ->
84  
-              if $(@).not(":selected")
  84
+              if not $(@).is(":selected")
85 85
                 $(@).remove()
86 86
               else
87 87
                 selected_values.push $(@).val() + "-" + $(@).text()

0 notes on commit 63a7728

Please sign in to comment.
Something went wrong with that request. Please try again.