nested_form_fields 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/assets/javascripts/nested_form_fields.js.coffee +3 -3
- data/lib/nested_form_fields/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02d61af1c6293f8421ae8e3c0d9239786a0b67aa
|
4
|
+
data.tar.gz: 362b4669eb7a3826512a3c3832bfe39538aeb1f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f679f1cdaaaeb1c1c931541c3f3739c2647b75e7ec90c3ebc7fb6b439fcda2540861bb0e36fe3ae652b351c22d2466e174c7bacbc3fbbada57ba08f66a40fa62
|
7
|
+
data.tar.gz: ad09cd926e9304264bb0f8b1dd741b5eb06582d23e545727b6abe7b01abc6a18148f6933d00dc07d5c1395063b8fa918ed7d840894ebe0951ff34becc583e9bc
|
data/README.md
CHANGED
@@ -177,6 +177,17 @@ $(document).on "fields_added.nested_form_fields", (event, param) ->
|
|
177
177
|
console.log "INFO: Fields were successfully added, callback not handled."
|
178
178
|
```
|
179
179
|
|
180
|
+
You can pass any additional data to the event's callback. This may be useful if you trigger them programmatically. Example:
|
181
|
+
|
182
|
+
```coffeescript
|
183
|
+
# Trigger button click programmatically and pass an object `{hello: 'world'}`
|
184
|
+
$('.add_nested_fields_link').trigger('click', [{hello: 'world'}])
|
185
|
+
|
186
|
+
# Listen for the event
|
187
|
+
$(document).on "fields_added.nested_form_fields", (event, param) ->
|
188
|
+
console.log param.additional_data #=> {hello: 'world'}
|
189
|
+
```
|
190
|
+
|
180
191
|
## Index replacement string
|
181
192
|
|
182
193
|
Sometimes your code needs to know what index it has when it is instantiated onto the page.
|
@@ -2,12 +2,12 @@ window.nested_form_fields or= {}
|
|
2
2
|
|
3
3
|
nested_form_fields.bind_nested_forms_links = () ->
|
4
4
|
$('body').off("click", '.add_nested_fields_link')
|
5
|
-
$('body').on 'click', '.add_nested_fields_link', (event) ->
|
5
|
+
$('body').on 'click', '.add_nested_fields_link', (event, additional_data) ->
|
6
6
|
$link = $(this)
|
7
7
|
object_class = $link.data('object-class')
|
8
8
|
association_path = $link.data('association-path')
|
9
9
|
added_index = $(".nested_#{association_path}").length
|
10
|
-
$.event.trigger("fields_adding.nested_form_fields",{object_class: object_class, added_index: added_index, association_path: association_path});
|
10
|
+
$.event.trigger("fields_adding.nested_form_fields",{object_class: object_class, added_index: added_index, association_path: association_path, additional_data: additional_data});
|
11
11
|
if $link.data('scope')
|
12
12
|
$template = $("#{$link.data('scope')} ##{association_path}_template")
|
13
13
|
else
|
@@ -33,7 +33,7 @@ nested_form_fields.bind_nested_forms_links = () ->
|
|
33
33
|
$('#' + target).append($parsed_template)
|
34
34
|
else
|
35
35
|
$template.before( $parsed_template )
|
36
|
-
$parsed_template.trigger("fields_added.nested_form_fields", {object_class: object_class, added_index: added_index, association_path: association_path, event: event});
|
36
|
+
$parsed_template.trigger("fields_added.nested_form_fields", {object_class: object_class, added_index: added_index, association_path: association_path, event: event, additional_data: additional_data});
|
37
37
|
false
|
38
38
|
|
39
39
|
$('body').off("click", '.remove_nested_fields_link')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested_form_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nico Ritsche
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|