Skip to content

Commit

Permalink
allow duplicate selections.
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed Nov 19, 2011
1 parent 4744549 commit 8ad38d9
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions jquery.autoSuggest.js
Expand Up @@ -271,10 +271,18 @@
} }
} }
if(str){ if(str){
if (!opts.matchCase){ str = str.toLowerCase(); } if (!opts.matchCase){ str = str.toLowerCase(); }
if(str.search(query) != -1 && values_input.val().search(","+data[num][opts.selectedValuesProp]+",") == -1){ // Figure out whether to move forward based on
forward = true; // 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){ if(forward){
var formatted = $('<li class="as-result-item" id="as-result-item-'+num+'"></li>').click(function(){ var formatted = $('<li class="as-result-item" id="as-result-item-'+num+'"></li>').click(function(){
Expand Down Expand Up @@ -365,4 +373,4 @@
}); });
} }
} }
})(jQuery); })(jQuery);

0 comments on commit 8ad38d9

Please sign in to comment.