Now let's allow our users to edit the Album info.
This sprint we will:
- make it so users can edit each Album
- add a
PUT /api/albums/:id
route to the server
Note: as we go through this if you get stuck make use of the hints, your neighbors and the solutions.
You must complete all of the previous sprint before starting this sprint. (excludes stretch challenges)
We're going to add a button that allows our users to edit an album.
- Add a new button to each panel-footer
<button class='btn btn-info edit-album'>Edit Album</button>`
-
Use jQuery to react to clicks on these buttons and determine the correct
Album._id
.console.log
it. -
Replace the
Edit
button with aSave Changes
button when clicked. -
Also replace the major fields on the Album with
input
elements.
Hint: you could have 2 buttons in place already, 1) "Edit", 2) "Save changes" and simply toggle their visibility with $.toggle
-
When
Save Changes
is clicked, react to it. -
Prepare an AJAX call to the server at
PUT /api/albums/:id
.
-
Add the
app.put
method on the server. -
Connect it to the database.
-
Make any final changes to your AJAX and test everything.
-
When an edit is in progress disable or hide the other buttons.
-
Add a new modal instead of making changes directly in the album row.
-
Add a cancel button for the edits