Deleting Rows
Learn how to remove rows dynamically.
We'll cover the following...
We'll cover the following...
All that is left now is to make the “Remove” links work. We’ll add a bit of JavaScript to remove the row that the “Remove” button is part of.
Updating the fragment
Let’s update the edit-teamplayer-fragment:
We’ll add three attributes to the <a> element:
-
x-datato define a new AlpineJS scope. -
th:attrto add the current index parameter of the fragment so we can read this from JavaScript and know what row we should delete. -
@clickto trigger the actual removal of the row when the link is clicked. ...