rails3-jquery-autocomplete 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -20,3 +20,5 @@ pkg
20
20
  tmp
21
21
 
22
22
  ## PROJECT::SPECIFIC
23
+ .bundle
24
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # A sample Gemfile
2
+ source :gemcutter
3
+ #
4
+ gem 'rails', '3.0.0.rc'
5
+ gem 'sqlite3-ruby'
6
+ gem 'jeweler'
data/Gemfile.lock ADDED
@@ -0,0 +1,83 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.0.rc)
6
+ actionpack (= 3.0.0.rc)
7
+ mail (~> 2.2.5)
8
+ actionpack (3.0.0.rc)
9
+ activemodel (= 3.0.0.rc)
10
+ activesupport (= 3.0.0.rc)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.4.1)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.9)
16
+ rack-test (~> 0.5.4)
17
+ tzinfo (~> 0.3.22)
18
+ activemodel (3.0.0.rc)
19
+ activesupport (= 3.0.0.rc)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.4.1)
22
+ activerecord (3.0.0.rc)
23
+ activemodel (= 3.0.0.rc)
24
+ activesupport (= 3.0.0.rc)
25
+ arel (~> 0.4.0)
26
+ tzinfo (~> 0.3.22)
27
+ activeresource (3.0.0.rc)
28
+ activemodel (= 3.0.0.rc)
29
+ activesupport (= 3.0.0.rc)
30
+ activesupport (3.0.0.rc)
31
+ arel (0.4.0)
32
+ activesupport (>= 3.0.0.beta)
33
+ builder (2.1.2)
34
+ erubis (2.6.6)
35
+ abstract (>= 1.0.0)
36
+ gemcutter (0.6.1)
37
+ git (1.2.5)
38
+ i18n (0.4.1)
39
+ jeweler (1.4.0)
40
+ gemcutter (>= 0.1.0)
41
+ git (>= 1.2.5)
42
+ rubyforge (>= 2.0.0)
43
+ json_pure (1.4.6)
44
+ mail (2.2.5)
45
+ activesupport (>= 2.3.6)
46
+ mime-types
47
+ treetop (>= 1.4.5)
48
+ mime-types (1.16)
49
+ polyglot (0.3.1)
50
+ rack (1.2.1)
51
+ rack-mount (0.6.10)
52
+ rack (>= 1.0.0)
53
+ rack-test (0.5.4)
54
+ rack (>= 1.0)
55
+ rails (3.0.0.rc)
56
+ actionmailer (= 3.0.0.rc)
57
+ actionpack (= 3.0.0.rc)
58
+ activerecord (= 3.0.0.rc)
59
+ activeresource (= 3.0.0.rc)
60
+ activesupport (= 3.0.0.rc)
61
+ bundler (>= 1.0.0.rc.1)
62
+ railties (= 3.0.0.rc)
63
+ railties (3.0.0.rc)
64
+ actionpack (= 3.0.0.rc)
65
+ activesupport (= 3.0.0.rc)
66
+ rake (>= 0.8.3)
67
+ thor (~> 0.14.0)
68
+ rake (0.8.7)
69
+ rubyforge (2.0.4)
70
+ json_pure (>= 1.1.7)
71
+ sqlite3-ruby (1.3.1)
72
+ thor (0.14.0)
73
+ treetop (1.4.8)
74
+ polyglot (>= 0.3.1)
75
+ tzinfo (0.3.22)
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ jeweler
82
+ rails (= 3.0.0.rc)
83
+ sqlite3-ruby
data/README.markdown CHANGED
@@ -1,6 +1,7 @@
1
1
  # rails3-jquery-autocomplete
2
2
 
3
- An easy way to use jQuery's autocomplete with Rails 3
3
+ An easy way to use jQuery's autocomplete with Rails 3. You can find a [detailed example](http://github.com/crowdint/rails3-jquery-autocomplete-app)
4
+ on how to use this gem [here](http://github.com/crowdint/rails3-jquery-autocomplete-app).
4
5
 
5
6
  ## Before you start
6
7
 
@@ -39,12 +40,12 @@ And include autocomplete-rails.js on your layouts
39
40
 
40
41
  Assuming you have a Brand model:
41
42
 
42
- class Brand < ActiveRecord::Base
43
- end
43
+ class Brand < ActiveRecord::Base
44
+ end
44
45
 
45
- create_table :brand do |t|
46
- t.column :name, :string
47
- end
46
+ create_table :brand do |t|
47
+ t.column :name, :string
48
+ end
48
49
 
49
50
  ### Controller
50
51
 
@@ -75,7 +76,7 @@ The following terms would match the query 'un':
75
76
  * Unacceptable
76
77
  * Rerun
77
78
 
78
- #### :full => false
79
+ #### :full => false (default behavior)
79
80
 
80
81
  Only the following terms mould match the query 'un':
81
82
 
@@ -94,3 +95,31 @@ This will generate an HTML tag that looks like:
94
95
  <input type="text" autocomplete="products/autocomplete_brand_name">
95
96
 
96
97
  Now your autocomplete JS code is unobtrusive, Rails 3 style.
98
+
99
+ ### Getting the object id
100
+
101
+ If you need to use the id of the selected object, you can use the *:id_element* HTML tag too:
102
+
103
+ f.text_field :brand_name, :autocomplete => autocomplete_brand_name_products_path, :id_element => '#some_element'
104
+
105
+ 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.
106
+
107
+ ## Development
108
+
109
+ If you want to make changes to the gem, first install bundler 1.0.0:
110
+
111
+ gem install bundler --pre
112
+
113
+ And then, install all your dependecies:
114
+
115
+ bundle install
116
+
117
+ ### Running the test suite
118
+
119
+ rake test
120
+
121
+ # About the Author
122
+
123
+ [Crowd Interactive](http://www.crowdint.com) is an American web design and development company that happens to work in Colima, Mexico.
124
+ We specialize in building and growing online retail stores. We don’t work with everyone – just companies we believe in. Call us today to see if there’s a fit.
125
+ Find more info [here](http://www.crowdint.com)!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -6,13 +6,24 @@
6
6
  *
7
7
  * Example:
8
8
  * <input type="text" autocomplete="/url/to/autocomplete">
9
- *
9
+ *
10
+ * Optionally, you can use a jQuery selector to specify a field that can
11
+ * be updated with the element id whenever you find a matching value
12
+ *
13
+ * Example:
14
+ * <input type="text" autocomplete="/url/to/autocomplete" id_element="#id_field">
10
15
  */
11
16
 
12
17
  $(document).ready(function(){
13
18
  $('input[autocomplete]').each(function(i){
14
19
  $(this).autocomplete({
15
- source: $(this).attr('autocomplete')
16
- });
20
+ source: $(this).attr('autocomplete'),
21
+ select: function(event, ui) {
22
+ if($(this).attr('id_element')) {
23
+ $($(this).attr('id_element')).val(ui.item.id);
24
+ }
25
+ return false;
26
+ }
27
+ });
17
28
  });
18
29
  });
@@ -27,7 +27,6 @@ module Rails3JQueryAutocomplete
27
27
  def autocomplete(object, method, options = {})
28
28
  limit = options[:limit] || 10
29
29
  order = options[:order] || "#{method} ASC"
30
- inner = options[:full] || false
31
30
 
32
31
  define_method("autocomplete_#{object}_#{method}") do
33
32
  unless params[:term] && params[:term].empty?
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3-jquery-autocomplete}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Padilla"]
12
- s.date = %q{2010-07-25}
12
+ s.date = %q{2010-08-20}
13
13
  s.description = %q{Use jQuery's autocomplete plugin with Rails 3.}
14
14
  s.email = %q{david.padilla@crowdint.com}
15
15
  s.extra_rdoc_files = [
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
+ "Gemfile",
23
+ "Gemfile.lock",
22
24
  "LICENSE",
23
25
  "README.markdown",
24
26
  "Rakefile",
data/test/test_helper.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'test/unit'
2
2
 
3
3
  require 'rubygems'
4
- gem 'rails', '>=3.0.0.beta4'
4
+ gem 'rails', '>=3.0.0.rc'
5
+ gem 'sqlite3-ruby'
5
6
 
6
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
8
  $LOAD_PATH.unshift(File.dirname(__FILE__))
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
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-07-25 00:00:00 -05:00
18
+ date: 2010-08-20 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -31,6 +31,8 @@ extra_rdoc_files:
31
31
  files:
32
32
  - .document
33
33
  - .gitignore
34
+ - Gemfile
35
+ - Gemfile.lock
34
36
  - LICENSE
35
37
  - README.markdown
36
38
  - Rakefile