diff options
author | jzaefferer <joern.zaefferer@gmail.com> | 2010-04-16 11:05:35 +0200 |
---|---|---|
committer | jzaefferer <joern.zaefferer@gmail.com> | 2010-04-16 11:05:35 +0200 |
commit | dbc9addfae0c9a2aee2d4a1833b2b1d3ba83f8de (patch) | |
tree | 0bc04f8f3728b660b37655c2166a7648c6574f3c /ui/jquery.ui.autocomplete.js | |
parent | cddf2a45da7195fadbe17353917cd086831c4313 (diff) | |
download | jquery-ui-dbc9addfae0c9a2aee2d4a1833b2b1d3ba83f8de.tar.gz jquery-ui-dbc9addfae0c9a2aee2d4a1833b2b1d3ba83f8de.zip |
Autocomplete: Refactored code for array filtering into $.ui.autocomplete.filter, used by remote-with-cache and modified multiple-demo (now with local data); added multiple-remote to also show multiple with remote data
Diffstat (limited to 'ui/jquery.ui.autocomplete.js')
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 14a19e4b2..070045d16 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -166,11 +166,7 @@ $.widget( "ui.autocomplete", { if ( $.isArray(this.options.source) ) { array = this.options.source; this.source = function( request, response ) { - // escape regex characters - var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); - response( $.grep( array, function(value) { - return matcher.test( value.label || value.value || value ); - }) ); + response( $.ui.autocomplete.filter(array, request.term) ); }; } else if ( typeof this.options.source === "string" ) { url = this.options.source; @@ -308,6 +304,12 @@ $.widget( "ui.autocomplete", { $.extend( $.ui.autocomplete, { escapeRegex: function( value ) { return value.replace( /([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1" ); + }, + filter: function(array, term) { + var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" ); + return $.grep( array, function(value) { + return matcher.test( value.label || value.value || value ); + }); } }); |