README.markdown in rails3-jquery-autocomplete-0.8.0 vs README.markdown in rails3-jquery-autocomplete-0.9.0
- old
+ new
@@ -144,11 +144,11 @@
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)
+This wouldn't really make much sense unless you use it with the "id_element" attribute. (See below)
Only the object's id and the column you are searching on will be returned in JSON, so if your display_value method requires another parameter, make sure to fetch it with the :extra_data option
#### :scopes
@@ -157,10 +157,19 @@
#### :column_name
By default autocomplete uses method name as column name. Now it can be specified using column_name options
`:column_name => 'name'`
+#### json encoder
+Autocomplete uses Yajl as JSON encoder/decoder, but you can specify your own
+
+ class ProductsController < Admin::BaseController
+ autocomplete :brand, :name do |items|
+ CustomJSON::Encoder.encode(items)
+ end
+ end
+
### 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.
@@ -181,10 +190,10 @@
Now your autocomplete code is unobtrusive, Rails 3 style.
### Getting the object id
-If you need to use the id of the selected object, you can use the *:id_element* HTML tag too:
+If you need to use the id of the selected object, you can use the *id_element* attribute too:
f.autocomplete_field :brand_name, autocomplete_brand_name_products_path, :id_element => '#some_element'
This will update the field with id *#some_element with the id of the selected object. The value for this option can be any jQuery selector.