Editing a Reddit Post
Here we go - the biggy. The U in CRUD.😟😟
Update
Update Is the hardest part of CRUD for a couple reasons, but as I am an API and only focusing on client-side development things should be a little easier.
The main challenge is visually creating an application that previews the current status of an item to be edited, and then an updated version once you complete the request.
For this, I have used a series of buttons, with some handy JQuery helpers to assist.
Once the dynamically generated button is pressed, then the button is located and replaced with the 'confirm' button using JQuery's '.replaceWith()'.
The body of the post (or 'selftext') is then found, and replaced with a form. This form contains an input box with the original body of the post as a value.
From here, the user can change the text and press confirm, which will trigger the ajax request.
Comments
Post a Comment