This is Part 3 of Real Time Commenting System Functionality.
Part 1 and Part 2 are Prerequisites of Part 3.
Real Time Commenting System | Part 1
Real Time Commenting System | Part 2
Now you will be able to Edit and Delete your comments.
These additions are made just by creating two new functions.
Functions
editBtn_click
deleteBtn_click
editBtn_click
disable the comment and delete buttons
get the repeater data in commentData variable
find the index of selected comment
get the data of selected comment in editCommentData variable
If the label of button is edit then set the value of comment input box to selected comment and change the label of button to "Save"
else get the edited comment in editedComment variable
update the data of selected comment using editedComment
update commentData and set this to repeater data
fill the repeater with updated data
set the value of comment Input box to null
after 100ms, collapse the comment box and empty the placeholder of comment Input box
change the label of button to "Edit"
enable the comment and delete button

deleteBtn_click
get the repeater data in commentData variable
find the index of selected comment
get the id of all the selected sub-comments of selected comment in itemIdArr variable using for loop
remove the selected comments and its sub-comments from commentData using splice function
update the repeater data
set the value of commentInput to null
after 100ms, collapse the input box and empty the placeholder of comment input box

- Priyanka Verma