Skip to content

Commit 5b3a3bc

Browse files
committed
Committing v1.3.0 of plugin
1 parent 43b1a48 commit 5b3a3bc

File tree

3 files changed

+12
-40
lines changed

3 files changed

+12
-40
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Rhyzz
3+
Copyright (c) 2014-2015 Rhyzz
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

repeatable-fields.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "repeatable-fields",
3-
"version": "1.2",
3+
"version": "1.3.0",
44
"title": "Repeatable Fields",
55
"author": {
66
"name": "Rhyzz",

repeatable-fields.js

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* jQuery Repeatable Fields v1.2
2+
* jQuery Repeatable Fields v1.3.0
33
* http://www.rhyzz.com/repeatable-fields.html
44
*
5-
* Copyright (c) 2014 Rhyzz
5+
* Copyright (c) 2015 Rhyzz
66
* License MIT
77
*/
88

@@ -40,19 +40,11 @@
4040
$(this).prop('disabled', true);
4141
});
4242

43-
var row_count = 1;
43+
var row_count = $(container).children(settings.row).filter(function() {
44+
return !$(this).hasClass(settings.template.replace('.', ''));
45+
}).length;
4446

45-
$(container).children(settings.row).each(function() {
46-
if($(this).hasClass(settings.template.replace('.', '')) === true) {
47-
return true;
48-
}
49-
50-
var current_row_count = $(this).data('rf-row-count');
51-
52-
$(this).attr('data-rf-row-count', row_count);
53-
54-
row_count++;
55-
});
47+
$(container).attr('data-rf-row-count', row_count);
5648

5749
$(wrapper).on('click', settings.add, function(event) {
5850
event.stopImmediatePropagation();
@@ -105,37 +97,17 @@
10597
}
10698

10799
function after_add(container, new_row) {
108-
var row_count;
109-
110-
$(new_row).parent(settings.container).children(settings.row).each(function() {
111-
if($(this).hasClass(settings.template.replace('.', '')) === true) {
112-
return true;
113-
}
114-
115-
var current_row_count = $(this).data('rf-row-count');
100+
var row_count = $(container).attr('data-rf-row-count');
116101

117-
if(typeof current_row_count === 'undefined') {
118-
var current_row_count = $(container).children(settings.row).filter(function() {
119-
return !$(this).hasClass(settings.template.replace('.', ''));
120-
}).length;
121-
}
122-
else {
123-
current_row_count++;
124-
}
125-
126-
if(typeof row_count === 'undefined' || current_row_count > row_count) {
127-
row_count = current_row_count;
128-
}
129-
130-
});
131-
132-
$(new_row).attr('data-rf-row-count', row_count);
102+
row_count++;
133103

134104
$('*', new_row).each(function() {
135105
$.each(this.attributes, function(index, element) {
136106
this.value = this.value.replace(/{{row-count-placeholder}}/, row_count - 1);
137107
});
138108
});
109+
110+
$(container).attr('data-rf-row-count', row_count);
139111
}
140112
}
141113
})(jQuery);

0 commit comments

Comments
 (0)