README.markdown in rails3-jquery-autocomplete-0.2.2 vs README.markdown in rails3-jquery-autocomplete-0.2.3

- old
+ new

@@ -60,18 +60,20 @@ resources :products do get :autocomplete_brand_name, :on => :collection end +### Options + +#### :full => true + By default, the search starts from the beginning of the string you're searching for. If you want to do a full search, set the _full_ parameter to true. class ProductsController < Admin::BaseController autocomplete :brand, :name, :full => true end -#### :full => true - The following terms would match the query 'un': * Luna * Unacceptable * Rerun @@ -80,10 +82,31 @@ Only the following terms mould match the query 'un': * Unacceptable +#### :display_value + +If you want to display a different version of what you're looking for, you can use the :display_value option. + +This options receives a method name as the parameter, and that method will be called on the instance when displaying the results. + + class Brand < ActiveRecord::Base + def funky_method + "#{self.name}.camelize" + end + end + + + class ProductsController < Admin::BaseController + autocomplete :brand, :name, :display_value => :funky_method + end + +In the example above, you will search by _name_, but the autocomplete list will display the result of _funky_method_ + +This wouldn't really make much sense unless you use it with the :id_element HTML tag. (See below) + ### View On your view, all you have to do is include the attribute autocomplete on the text field using the url to the autocomplete action as the value. form_for @product do |f| @@ -108,10 +131,10 @@ If you want to make changes to the gem, first install bundler 1.0.0: gem install bundler --pre -And then, install all your dependecies: +And then, install all your dependencies: bundle install ### Running the test suite \ No newline at end of file