README.md in rails3-jquery-autocomplete-1.0.14 vs README.md in rails3-jquery-autocomplete-1.0.15
- old
+ new
@@ -262,10 +262,19 @@
'data-delimiter' => ',', :multiple => true
end
NOTE: Setting the `:multiple` option to `true` will result in the chosen values being submitted as an array. Leaving this option off will result in the values being passed as a single string, with the values separated by your chosen delimiter.
+#### Automatically focus on the first autocompleted item
+
+To have the first item be automatically focused on when the autocomplete menu is shown, add the `'data-auto-focus'` option and set it to `true`.
+
+ form_for @product do |f|
+ f.autocomplete_field :brand_names, autocomplete_brand_name_products_path,
+ 'data-auto-focus' => true
+ end
+
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* attribute too:
@@ -304,11 +313,9 @@
country = params[:country]
products = Product.where('brand = ? AND country = ? AND name LIKE ?', brand_id, country, "%#{term}%").order(:name).all
render :json => products.map { |product| {:id => product.id, :label => product.name, :value => product.name} }
end
end
-
-The previous example would fetch the extra attribute slogan and update jQuery('#some_other_element') with the slogan value.
### Getting extra object data
If you need to extra data about the selected object, you can use the *:update_elements* HTML attribute.