Autocomplete lists should be based on "q" parameter

If you don't filter server-side, the user sees the full list until
another character is entered.
This commit is contained in:
Eric Allen 2010-04-02 13:36:25 -04:00
parent 9ccd6d11d8
commit c79d1c964a
4 changed files with 6 additions and 5 deletions

View file

@ -124,8 +124,9 @@ class ApplicationController < ActionController::Base
end
def for_autocomplete(coll)
coll.map {|item| "#{item.name}|#{item.id}"}.join("\n")
def for_autocomplete(coll, substr)
filtered = coll.find_all{|item| item.name.downcase.include? substr.downcase}
return filtered.map {|item| "#{item.name}|#{item.id}"}.join("\n")
end
# Uses RedCloth to transform text using either Textile or Markdown Need to