filmov
tv
AJAX - Comment Box with [ Javascript jQuery JSON PHP MySQL ] - Step by Step How to Guide - Part 18
Показать описание
In this last and final tutorial of this series, I talk about making sure that when a new comment is inserted to the list, then the user cannot immediately delete the same comment which they have made, due to the fact that we havent set an event handler on newly inserted objects.
When we first loaded the page, we looped through all delete-btn's and attach an event handler. Therefore the only thing which we need to do once we have inserted a new comment into the list, is to run the same loop once again, to reattach new event handlers.
So we basically take the code which we wrote before and place it into a function so as we then dont have to rewrite the same code.
Finally I then talk about how to only allow the user which has entered the comment be able to delete it. As you know at the beginning we made 2 input elements of type hidden holding the userId and userName. We use this information to act as the cookie which would be stored on the client when the user has logged in.
Once this has been done, all works just fine.
When we first loaded the page, we looped through all delete-btn's and attach an event handler. Therefore the only thing which we need to do once we have inserted a new comment into the list, is to run the same loop once again, to reattach new event handlers.
So we basically take the code which we wrote before and place it into a function so as we then dont have to rewrite the same code.
Finally I then talk about how to only allow the user which has entered the comment be able to delete it. As you know at the beginning we made 2 input elements of type hidden holding the userId and userName. We use this information to act as the cookie which would be stored on the client when the user has logged in.
Once this has been done, all works just fine.
Комментарии