Skip to content

Commit db4f44d

Browse files
committed
minor #10717 Fix example for collection form type (kunicmarko20)
This PR was squashed before being merged into the 3.4 branch (closes #10717). Discussion ---------- Fix example for collection form type If I am correct ``` | list.children().length; ``` does the same thing as the line I removed. Commits ------- 2f1cc8d Fix example for collection form type
2 parents a21e573 + 2f1cc8d commit db4f44d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

reference/forms/types/collection.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,8 @@ you need is this JavaScript code:
146146
jQuery(document).ready(function () {
147147
jQuery('.add-another-collection-widget').click(function (e) {
148148
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
150150
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; }
153151
154152
// grab the prototype template
155153
var newWidget = list.attr('data-prototype');
@@ -160,7 +158,7 @@ you need is this JavaScript code:
160158
// Increase the counter
161159
counter++;
162160
// 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);
164162
165163
// create a new list element and add it to the list
166164
var newElem = jQuery(list.attr('data-widget-tags')).html(newWidget);

0 commit comments

Comments
 (0)