Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [Forms] Use regular JavaScript functions in the examples
  • Loading branch information
javiereguiluz committed Feb 19, 2024
2 parents 8506e11 + bff80df commit 823b9ca
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ you'll replace with a unique, incrementing number (e.g. ``task[tags][3][name]``)

.. code-block:: javascript
const addFormToCollection = (e) => {
function addFormToCollection(e) {
const collectionHolder = document.querySelector('.' + e.currentTarget.dataset.collectionHolderClass);
const item = document.createElement('li');
Expand Down Expand Up @@ -579,7 +579,8 @@ on the server. In order for this to work in an HTML form, you must remove
the DOM element for the collection item to be removed, before submitting
the form.

First, add a "delete this tag" link to each tag form:
In the JavaScript code, add a "delete" button to each existing tag on the page.
Then, append the "add delete button" method in the function that adds the new tags:

.. code-block:: javascript
Expand All @@ -591,7 +592,7 @@ First, add a "delete this tag" link to each tag form:
// ... the rest of the block from above
const addFormToCollection = (e) => {
function addFormToCollection(e) {
// ...
// add a delete link to the new form
Expand All @@ -602,7 +603,7 @@ The ``addTagFormDeleteLink()`` function will look something like this:

.. code-block:: javascript
const addTagFormDeleteLink = (item) => {
function addTagFormDeleteLink(item) {
const removeFormButton = document.createElement('button');
removeFormButton.innerText = 'Delete this tag';
Expand Down

0 comments on commit 823b9ca

Please sign in to comment.