We now know how to build a REST API to fetch and create data, but what if our client has moved to a new office or changed their phone number?
We will need to have a way to modify our client's data and this is what we will learn in this recipe.
We will keep evolving the code that we have created in the last recipe. So, again, you can duplicate the last section's project or just modify it.
In the
index.html
file, create a new column in the table to hold the edit link:<th>Edit</th>
Create a new function called
createLine
, which should have the same code as thecreateClient's newLine
variable. This code is as follows :var createLine = function(data) { return <place the code from the newLine variable here> };
Then add the new column, by adding the following code:
' <td><a href="#" class="edit" data-id="' + data.id + '" onclick="editClient(this)">Edit</a></td>...