Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow duplicate selections.

  • Loading branch information...
commit 8ad38d94521505ce3f1d80ce5b1669215a61b701 1 parent 4744549
@smith smith authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 jquery.autoSuggest.js
View
18 jquery.autoSuggest.js
@@ -271,10 +271,18 @@
}
}
if(str){
- if (!opts.matchCase){ str = str.toLowerCase(); }
- if(str.search(query) != -1 && values_input.val().search(","+data[num][opts.selectedValuesProp]+",") == -1){
- forward = true;
- }
+ if (!opts.matchCase){ str = str.toLowerCase(); }
+ // Figure out whether to move forward based on
+ // conditions. If the query matches, and the
+ // allowDuplicates options is set, forward. If that
+ // option is not set, make we're not looking for
+ // an item that has already been selected.
+ forward = str.search(query) != -1 &&
+ (opts.allowDuplicates ? true :
+ values_input.val().search("," +
+ data[num][opts.selectedValuesProp] +
+ ",") == -1
+ );
}
if(forward){
var formatted = $('<li class="as-result-item" id="as-result-item-'+num+'"></li>').click(function(){
@@ -365,4 +373,4 @@
});
}
}
-})(jQuery);
+})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.