searchify 0.0.6 → 0.0.7
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/README.md
CHANGED
@@ -23,7 +23,7 @@ Add both jquery-ui and searchify to your `app/assets/javascripts/application.js`
|
|
23
23
|
//= require jquery-ui
|
24
24
|
//= require searchify/searchify
|
25
25
|
|
26
|
-
Finally, call the `searchify()` method on all `.searchify`
|
26
|
+
Finally, call the `searchify()` method on all `.searchify` fields.
|
27
27
|
|
28
28
|
$('.searchify').searchify();
|
29
29
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
source: $(this).data("search-url"),
|
6
6
|
select: function (event, ui) {
|
7
7
|
if (select_url = $(this).data("select-url"))
|
8
|
-
window.location.href =
|
8
|
+
window.location.href = select_url.replace(/\(id\)/, ui.item.id);
|
9
9
|
else
|
10
10
|
$(this).prev().val(ui.item.id);
|
11
11
|
}
|
@@ -66,10 +66,16 @@ class ActionView::Helpers::FormBuilder
|
|
66
66
|
options[:class] = [:searchify].push(options[:class]).flatten.compact
|
67
67
|
options[:data] = {:'search-url' => search_url}.merge(options[:data] || {})
|
68
68
|
|
69
|
+
# default id
|
70
|
+
options[:id] ||= "#{object_name.gsub(/\[/, '_').gsub(/\]/, '')}_#{field_name}"
|
71
|
+
|
69
72
|
# value
|
70
73
|
label_method = options.delete(:label_method) || Searchify::Config.label_method
|
74
|
+
|
75
|
+
# fetch the value only if object respond_to model_name
|
76
|
+
html_value = object.respond_to?(model_name) ? object.send(model_name).try(label_method) : ""
|
71
77
|
|
72
|
-
hidden_field(field_name) + @template.text_field_tag(:searchify,
|
78
|
+
hidden_field(field_name, :id => "#{options[:id]}_hidden") + @template.text_field_tag(:searchify, html_value, options)
|
73
79
|
end
|
74
80
|
|
75
81
|
protected
|
@@ -89,4 +95,4 @@ class ActionView::Helpers::FormBuilder
|
|
89
95
|
def extract_field_name(field)
|
90
96
|
field[/_id$/] ? field : "#{field}_id"
|
91
97
|
end
|
92
|
-
end
|
98
|
+
end
|
data/lib/searchify/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christian Blais
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-01 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|