nested_form_fields 0.7.7 → 0.7.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e9a9d80e8de459fc66f99524b4cd8745ee93f7b
4
- data.tar.gz: 96091b9aac3a10ddf9cddc50f3ddd81b91610e07
3
+ metadata.gz: 02d61af1c6293f8421ae8e3c0d9239786a0b67aa
4
+ data.tar.gz: 362b4669eb7a3826512a3c3832bfe39538aeb1f1
5
5
  SHA512:
6
- metadata.gz: 55b8fe3a713f864adcceb97ceb0e6e976c52145fa3c93d855176d25725a83ff087e704783496703a4b135d5669fe9cb9b57091f2f645d6f4157cf3401c0df643
7
- data.tar.gz: 3ad1d302024a32d97a5811f96821597d6069a88620824ec0c6bd85d3ced95d1c0614725a7d9e681af97ac67338bd38d08e043316c3d5f9762ac890ab5ea91143
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')
@@ -1,3 +1,3 @@
1
1
  module NestedFormFields
2
- VERSION = "0.7.7"
2
+ VERSION = "0.7.8"
3
3
  end
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.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-06 00:00:00.000000000 Z
11
+ date: 2016-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails