diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts b/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts index b48324786..875e99fad 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/module/collection/index.ts @@ -53,10 +53,13 @@ export const handleAdd = (button: any): void => { let empty_explain: HTMLLIElement | null = collection.querySelector('li[data-collection-empty-explain]'), entry = document.createElement('li'), - counter = collection.childNodes.length + 1, - content = prototype.replace(new RegExp('__name__', 'g'), counter.toString()), + counter = collection.querySelectorAll('li.entry').length, // Updated counter logic + content = prototype.replace(/__name__/g, counter.toString()), event = new CustomEvent('collection-add-entry', {detail: new CollectionEventPayload(collection, entry)}); + console.log(counter) + console.log(content) + entry.innerHTML = content; entry.classList.add('entry');