rails_ajax_formhandler 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +50 -55
- data/lib/rails_ajax_formhandler/version.rb +1 -1
- metadata +2 -3
- data/, +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: febcfbb6122cc883467826b050043a5f836a00a4
|
4
|
+
data.tar.gz: d34aac16aba237f793bcc48950190868b59c94a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4f3f0ebd17c79c1d9ca63c0cabe90a8f66dcbb46a627e6e12b30576021670a9e7690a1e895deb4a427ab804d5db6c5ae26fdbf499c831bb2473bbade356a063
|
7
|
+
data.tar.gz: 27df9404a2a88bac6bf758998b36d9b57586c9b3ab315eca7fb6bfc9932353cdc2edbcd1b04c2782aa2a3ef54db3202fe0ad570069164f396fab5815ff15caf8
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
In your application.js
|
30
30
|
|
31
|
-
```
|
31
|
+
```js
|
32
32
|
//=require ajax_formhandler
|
33
33
|
```
|
34
34
|
|
@@ -43,11 +43,11 @@ If you want to use built in validation-styles, add to your application.scss
|
|
43
43
|
This works with standard generated scaffold controllers, models and views seamlessely!
|
44
44
|
Just add the following line to your js-file, for example 'client.js':
|
45
45
|
|
46
|
-
```
|
46
|
+
```js
|
47
47
|
$(document).ready(function{
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
|
49
|
+
var form_handler = new FormHandler();
|
50
|
+
form_handler.init();
|
51
51
|
|
52
52
|
});
|
53
53
|
|
@@ -66,23 +66,23 @@ __Please note that in order to work, use the "form_for"-helper in your view as u
|
|
66
66
|
### html
|
67
67
|
accepts an object with the keys shown below
|
68
68
|
|
69
|
-
```
|
69
|
+
```js
|
70
70
|
{
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
71
|
+
html:{
|
72
|
+
wrapperTag: "div",
|
73
|
+
// each input field and label must be wrapped in order to apply the validation-error-markup
|
74
|
+
errorClassName: "fh-error-field",
|
75
|
+
// default, using the build-in styles
|
76
|
+
helpBlockClass: "help-block"
|
77
|
+
// default
|
78
|
+
},...
|
79
79
|
}
|
80
80
|
```
|
81
81
|
or, if you're using Bootstrap Version 3
|
82
82
|
|
83
|
-
```
|
83
|
+
```js
|
84
84
|
{
|
85
|
-
|
85
|
+
html: "bootstrap3",...
|
86
86
|
}
|
87
87
|
```
|
88
88
|
|
@@ -96,11 +96,11 @@ all callbacks accepting only a function
|
|
96
96
|
jqXHR as first, the form-object as second and the event as third argument
|
97
97
|
|
98
98
|
|
99
|
-
```
|
99
|
+
```js
|
100
100
|
{ ...
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
success: function(xhr, form, event) {
|
102
|
+
// what happens after success
|
103
|
+
}
|
104
104
|
}
|
105
105
|
```
|
106
106
|
|
@@ -109,11 +109,11 @@ jqXHR as first, the form-object as second and the event as third argument
|
|
109
109
|
jqXHR as first, the errorThrown(string) as second, the form-object as third and the event as forth argument
|
110
110
|
|
111
111
|
|
112
|
-
```
|
112
|
+
```js
|
113
113
|
{ ...
|
114
|
-
|
115
|
-
|
116
|
-
|
114
|
+
error: function(xhr,error, form, event) {
|
115
|
+
// any additional actions
|
116
|
+
}
|
117
117
|
}
|
118
118
|
```
|
119
119
|
|
@@ -121,27 +121,27 @@ jqXHR as first, the errorThrown(string) as second, the form-object as third and
|
|
121
121
|
event as only argument, will be called on submit
|
122
122
|
|
123
123
|
|
124
|
-
```
|
125
|
-
{
|
126
|
-
|
127
|
-
|
128
|
-
|
124
|
+
```js
|
125
|
+
{
|
126
|
+
send: function(event) {
|
127
|
+
// any additional actions
|
128
|
+
}
|
129
129
|
}
|
130
130
|
```
|
131
131
|
|
132
132
|
### *Example:*
|
133
133
|
|
134
134
|
|
135
|
-
```
|
135
|
+
```js
|
136
136
|
{ html: {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
137
|
+
wrapperTag: "div",
|
138
|
+
errorClass: "my-error-class",
|
139
|
+
helpBlockClass: "my-help-block"
|
140
|
+
},
|
141
|
+
success: function(xhr, form, event) {
|
142
|
+
$("#success-message").html("Form successfully submitted");
|
143
|
+
form[0].reset();
|
144
|
+
}
|
145
145
|
}
|
146
146
|
```
|
147
147
|
|
@@ -173,13 +173,13 @@ end
|
|
173
173
|
_Note_ that the json response in case of error works only if the json-string contains only the errors-object, or, if namespacing is required, the object name as key and the errors as values.
|
174
174
|
|
175
175
|
```ruby
|
176
|
-
|
176
|
+
f.json { render json: @client.errors, status: :unprocessable_entity }
|
177
177
|
|
178
178
|
```
|
179
179
|
or
|
180
180
|
|
181
181
|
```ruby
|
182
|
-
|
182
|
+
f.json { render json: { client: @client.errors, data: "some other stuff"}, status: :unprocessable_entity }
|
183
183
|
|
184
184
|
```
|
185
185
|
That gives you the possibility, passing some other informations alongside the errors-object, if required.
|
@@ -189,12 +189,11 @@ That gives you the possibility, passing some other informations alongside the er
|
|
189
189
|
Insert your validations in the model and pass your error-messages like:
|
190
190
|
|
191
191
|
|
192
|
-
```ruby
|
193
|
-
validates :firstname, presence: { message: "We need your firstname!"}
|
194
|
-
|
192
|
+
```ruby
|
193
|
+
validates :firstname, presence: { message: "We need your firstname!"}
|
195
194
|
```
|
196
195
|
|
197
|
-
|
196
|
+
More about rails validations: [http://guides.rubyonrails.org](http://guides.rubyonrails.org/active_record_validations.html).
|
198
197
|
|
199
198
|
|
200
199
|
## Multiple Forms
|
@@ -202,7 +201,7 @@ If you're not familiar with, please refer to [http://guides.rubyonrails.org](htt
|
|
202
201
|
If you have two or more forms on one page, FormHandler detects them all and sets them up. The passed arguments will be applied to each form. For specific configuration, call the ".config_form()"
|
203
202
|
method:
|
204
203
|
|
205
|
-
```
|
204
|
+
```js
|
206
205
|
|
207
206
|
var form_handler = new FormHandler({ html: "bootstrap3"})
|
208
207
|
|
@@ -237,21 +236,17 @@ would look like
|
|
237
236
|
In this case please make sure that the hidden-input appears _after_ the 'dummy-field', like in the example above in order to render validation errors properly!
|
238
237
|
|
239
238
|
|
240
|
-
## Support
|
241
|
-
|
242
|
-
I hope this usefull for you as it is for me. If there are any issues, pleas contact me [info@yield-in.de](info@yield-in.de)
|
243
|
-
|
244
|
-
|
245
|
-
## Development
|
246
239
|
|
247
|
-
|
240
|
+
## Contributing and Support
|
248
241
|
|
249
|
-
|
242
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/brancadavide/rails_ajax_formhandler.
|
243
|
+
For support just contact me [info@yield-in.de](mailto:info@yield-in.de)
|
250
244
|
|
251
|
-
##
|
245
|
+
## Credits
|
252
246
|
|
253
|
-
|
247
|
+
Author: Davide Brancaccio
|
254
248
|
|
249
|
+
You're welcome to join the contributors-list!
|
255
250
|
|
256
251
|
## License
|
257
252
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_ajax_formhandler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide Brancaccio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,7 +75,6 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- ","
|
79
78
|
- ".gitignore"
|
80
79
|
- CODE_OF_CONDUCT.md
|
81
80
|
- Gemfile
|
data/,
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'rails_ajax_formhandler/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "rails_ajax_formhandler"
|
8
|
-
spec.version = RailsAjaxFormhandler::VERSION
|
9
|
-
spec.authors = ["TODO: Write your name"]
|
10
|
-
spec.email = ["TODO: Write your email address"]
|
11
|
-
|
12
|
-
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
|
13
|
-
spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
-
spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
else
|
22
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
-
"public gem pushes."
|
24
|
-
end
|
25
|
-
|
26
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
f.match(%r{^(test|spec|features)/})
|
28
|
-
end
|
29
|
-
spec.bindir = "exe"
|
30
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = ["lib"]
|
32
|
-
|
33
|
-
spec.add_development_dependency "bundler", "~> 1.14"
|
34
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
-
end
|