dynamic_fields 0.3.2 → 0.3.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 +6 -0
- data/app/assets/javascripts/dynamic_fields/jquery.dynamic_fields.js +13 -10
- data/lib/dynamic_fields/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c7782de18661f1d656579c0823345c53778d23b
|
4
|
+
data.tar.gz: 4d081f29ec410831343c908a32d85f7fbec43a58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6926230579224265c1cc18f68ca84f8be7bb4c0185a8fd246cd1094c9a15dc172693ca30f3479dab481c46623e420bc8fe7a1a417f4832a1ea2dcd724b2a22fe
|
7
|
+
data.tar.gz: 9fc87a40fd43d91f9cbf27b2e71083878e9c7b2f2eb039df1eb208fca420826b1285867debef93b958456f53097aee7a8d2c1ea656e71046b5e06cbc1254d6b4
|
data/README.md
CHANGED
@@ -78,6 +78,12 @@ If you override the :class option, you will need to apply that to the Javascript
|
|
78
78
|
itemWrapper: ".nested_field"
|
79
79
|
})
|
80
80
|
|
81
|
+
The `removeFields` method may accept a hash of options as parameter. To change the confirmation message,
|
82
|
+
set the `confirmationMessage` value in the options hash. The default confirmation message is "Are you sure?".
|
83
|
+
|
84
|
+
$("body").delegate ".remove_dynamic_field", 'click', ->
|
85
|
+
$(this).removeFields({confirmationMessage: 'Deleting a record may have dire consequences; are you sure?'})
|
86
|
+
...
|
81
87
|
|
82
88
|
Example
|
83
89
|
--------
|
@@ -5,13 +5,16 @@
|
|
5
5
|
var options = $.extend(defaults, opts);
|
6
6
|
|
7
7
|
return $.dynamicFields.cloneFields(this, options);
|
8
|
-
}
|
8
|
+
};
|
9
|
+
|
10
|
+
$.fn.removeFields = function(opts){
|
11
|
+
var defaults = { confirmationMessage: 'Are you sure?' };
|
12
|
+
var options = $.extend(defaults, opts);
|
9
13
|
|
10
|
-
$.fn.removeFields = function(){
|
11
14
|
var $items = this.parent();
|
12
15
|
var destroy_field = $items.find("input[name$='[_destroy]']");
|
13
16
|
|
14
|
-
if (confirm(
|
17
|
+
if (confirm(options.confirmationMessage)) {
|
15
18
|
if (destroy_field[0] != undefined) {
|
16
19
|
destroy_field.val('true');
|
17
20
|
$items.hide();
|
@@ -25,11 +28,11 @@
|
|
25
28
|
})
|
26
29
|
}
|
27
30
|
}
|
28
|
-
return true
|
31
|
+
return true;
|
29
32
|
}else{
|
30
|
-
return false
|
33
|
+
return false;
|
31
34
|
}
|
32
|
-
}
|
35
|
+
};
|
33
36
|
|
34
37
|
$.dynamicFields = {
|
35
38
|
|
@@ -66,19 +69,19 @@
|
|
66
69
|
if ($(this)[0].type == 'textarea' || $(this)[0].type == 'text' || $(this)[0].type.match(/select/)){
|
67
70
|
$(this).val("");
|
68
71
|
}else if ($(this)[0].type == 'radio'){
|
69
|
-
$(this).attr("checked", false)
|
72
|
+
$(this).attr("checked", false);
|
70
73
|
}else if ($(this)[0].type == 'checkbox'){
|
71
|
-
$(this).attr("checked", false)
|
74
|
+
$(this).attr("checked", false);
|
72
75
|
}
|
73
76
|
|
74
|
-
})
|
77
|
+
});
|
75
78
|
|
76
79
|
item.find('label').each(function(){
|
77
80
|
if ($(this).attr('for')){
|
78
81
|
new_id = $(this).attr('for').replace(/\d/, ''+item_num);
|
79
82
|
$(this).attr('for', new_id);
|
80
83
|
}
|
81
|
-
})
|
84
|
+
});
|
82
85
|
|
83
86
|
item.insertAfter(origin);
|
84
87
|
return item;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jiongye Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
201
|
rubyforge_project:
|
202
|
-
rubygems_version: 2.
|
202
|
+
rubygems_version: 2.4.5.1
|
203
203
|
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: Generate dynamic fields for Rails
|