File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -146,10 +146,8 @@ you need is this JavaScript code:
146
146
jQuery (document ).ready (function () {
147
147
jQuery (' .add-another-collection-widget' ).click (function (e ) {
148
148
var list = jQuery (jQuery (this ).attr (' data-list' ));
149
- // Try to find the counter of the list
149
+ // Try to find the counter of the list or use the length of the list
150
150
var counter = list .data (' widget-counter' ) | list .children ().length ;
151
- // If the counter does not exist, use the length of the list
152
- if (! counter) { counter = list .children ().length ; }
153
151
154
152
// grab the prototype template
155
153
var newWidget = list .attr (' data-prototype' );
@@ -160,7 +158,7 @@ you need is this JavaScript code:
160
158
// Increase the counter
161
159
counter++ ;
162
160
// And store it, the length cannot be used if deleting widgets is allowed
163
- list .data (' widget-counter' , counter);
161
+ list .data (' widget-counter' , counter);
164
162
165
163
// create a new list element and add it to the list
166
164
var newElem = jQuery (list .attr (' data-widget-tags' )).html (newWidget);
You can’t perform that action at this time.
0 commit comments