nested_form_fields 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1946ea1089df972ab56caf9bc1c375eea103dd8d
4
- data.tar.gz: 969fa5a62bb63ce36273c01a368ca75c2f80773c
3
+ metadata.gz: 92c72a926632a8dc0558393682855c62e4a4ba39
4
+ data.tar.gz: bdaf269d3f7c98c30b67e410eac619cbb0329279
5
5
  SHA512:
6
- metadata.gz: 672badae02a7f04afda68746a49f6a15b99a4e4929ce37e0334b3bf3a74950acb2741511058346a1570c9b2fc7af9dfad6899ce02daf2c800b082dd1eb9bb0f3
7
- data.tar.gz: 1d108f7fc29d6925c4f9baae4deec59ae9e5efaae5a261bb0d37bfe7053b4569ab1118d7659137013e2488a0492019ed23b1826cd5265b3a1032cecd926f5d19
6
+ metadata.gz: d2f8674c9813f30b69e229fcfa16d2936ac442a6214a883a9c051f4a61c641ee68b1aa194b1898b1534912bcbc258b0c6200faf486a8ae2be3d5828e50603dd8
7
+ data.tar.gz: c8ee47add34f6956e827ca6ccc8d010e040f896eb1b1cdb6d0e6f1d846f14cca2b388b6c3a5ade92096bdf8e59f291ffa50321c77592c5561953136c83de385f
data/README.md CHANGED
@@ -80,8 +80,19 @@ You can pass options like you would to the `content_tag` method by nesting them
80
80
  There are 4 javascipt events firing before and after addition/removal of the fields in the *nested_form_fields* namespace. Namely:
81
81
  fields_adding, fields_added, fields_removing, fields_removed.
82
82
 
83
- CoffeeScript sample:
83
+ The events fields_added and fields_removed are triggered on the element being added or removed. The events bubble up so you can listen for them on any parent element.
84
+ This makes it easy to add listeners when you have multiple nested_form_fields on the same page.
84
85
 
86
+ CoffeeScript samples:
87
+
88
+ # Listen on an element
89
+ initializeSortable -> ($el)
90
+ $el.sortable(...)
91
+ $el.on 'fields_added.nested_form_fields', -> (event, param)
92
+ console.log event.target # The added field
93
+ console.log $(this) # $el
94
+
95
+ # Listen on document
85
96
  $(document).on "fields_added.nested_form_fields", (event,param) ->
86
97
  switch param.object_class
87
98
  when "video"
@@ -24,7 +24,7 @@ nested_form_fields.bind_nested_forms_links = () ->
24
24
  $child.replaceWith($("<script id='#{$child.attr('id')}' type='text/html' />").html($child.html()))
25
25
 
26
26
  $template.before( $parsed_template )
27
- $.event.trigger("fields_added.nested_form_fields",{object_class: object_class, added_index: added_index, association_path: association_path});
27
+ $parsed_template.trigger("fields_added.nested_form_fields", {object_class: object_class, added_index: added_index, association_path: association_path});
28
28
  false
29
29
 
30
30
  $('body').off("click", '.remove_nested_fields_link')
@@ -38,7 +38,7 @@ nested_form_fields.bind_nested_forms_links = () ->
38
38
  $nested_fields_container.before "<input type='hidden' name='#{delete_association_field_name}' value='1' />"
39
39
  $nested_fields_container.hide()
40
40
  $nested_fields_container.find('input[required]:hidden').removeAttr('required')
41
- $.event.trigger("fields_removed.nested_form_fields",{object_class: object_class, delete_association_field_name: delete_association_field_name, removed_index: removed_index});
41
+ $nested_fields_container.trigger("fields_removed.nested_form_fields",{object_class: object_class, delete_association_field_name: delete_association_field_name, removed_index: removed_index});
42
42
  false
43
43
 
44
44
  $(document).on "page:change", ->
@@ -1,3 +1,3 @@
1
1
  module NestedFormFields
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
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.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Ritsche
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails