rails3-jquery-autocomplete 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +10 -2
- data/lib/form_helper.rb +2 -2
- data/lib/generators/templates/autocomplete-rails.js +3 -5
- metadata +4 -4
data/README.markdown
CHANGED
@@ -20,7 +20,7 @@ I'd encourage you to understand how to use those 3 amazing tools before attempti
|
|
20
20
|
|
21
21
|
Include the gem on your Gemfile
|
22
22
|
|
23
|
-
gem 'rails3-jquery-autocomplete', '0.3.
|
23
|
+
gem 'rails3-jquery-autocomplete', '0.3.2'
|
24
24
|
|
25
25
|
Install it
|
26
26
|
|
@@ -115,6 +115,7 @@ This wouldn't really make much sense unless you use it with the :id_element HTML
|
|
115
115
|
|
116
116
|
On your view, all you have to do is include the attribute autocomplete on the text field
|
117
117
|
using the url to the autocomplete action as the value.
|
118
|
+
|
118
119
|
form_for @product do |f|
|
119
120
|
f.autocomplete_field :brand_name, autocomplete_brand_name_products_path
|
120
121
|
end
|
@@ -123,7 +124,14 @@ This will generate an HTML tag that looks like:
|
|
123
124
|
|
124
125
|
<input type="text" data-autocomplete="products/autocomplete_brand_name">
|
125
126
|
|
126
|
-
|
127
|
+
If you are not using a FormBuilder (form_for) or you just want to include an autocomplete field without the form, you can use the
|
128
|
+
*autocomplete_field_tag* helper.
|
129
|
+
|
130
|
+
form_tag 'some/path'
|
131
|
+
autocomplete_field_tag 'address', '', address_autocomplete_path, :size => 75
|
132
|
+
end
|
133
|
+
|
134
|
+
Now your autocomplete code is unobtrusive, Rails 3 style.
|
127
135
|
|
128
136
|
### Getting the object id
|
129
137
|
|
data/lib/form_helper.rb
CHANGED
@@ -50,7 +50,7 @@ module ActionView
|
|
50
50
|
end
|
51
51
|
|
52
52
|
class ActionView::Helpers::FormBuilder #:nodoc:
|
53
|
-
def autocomplete_field(method, options)
|
54
|
-
@template.autocomplete_field(@object_name, method, options)
|
53
|
+
def autocomplete_field(method, source, options = {})
|
54
|
+
@template.autocomplete_field(@object_name, method, source, options)
|
55
55
|
end
|
56
56
|
end
|
@@ -19,11 +19,9 @@ $(document).ready(function(){
|
|
19
19
|
$(this).autocomplete({
|
20
20
|
source: $(this).attr('data-autocomplete'),
|
21
21
|
select: function(event, ui) {
|
22
|
-
$(this).val(ui.item.value)
|
23
|
-
|
24
|
-
|
25
|
-
$($(this).attr('id_element')).val(ui.item.id);
|
26
|
-
}
|
22
|
+
$(this).val(ui.item.value);
|
23
|
+
if ($(this).attr('id_element')) {
|
24
|
+
$($(this).attr('id_element')).val(ui.item.id);
|
27
25
|
}
|
28
26
|
return false;
|
29
27
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails3-jquery-autocomplete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Padilla
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-12 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|