Answer the question
In order to leave comments, you need to log in
What is the best way to make comments in Ajax?
Hello. There is a site on Larevel 5.3
It is necessary to make comments on it. The comments themselves are ready, it remains to make a pagination for them.
I plan to make a "Show more" button at the bottom and load past comments with Ajax. Everything is clear with this, but there is one problem, if someone wrote a new comment, then it is loaded and becomes the first, or if 5 new ones are written, they will also appear.
How can I upload it in this case? Add to the date attribute the number of comments that are displayed and make an offset by that amount? And when loading new ones, change the value in the date attribute.
Is this normal or is there a better way to do this?
Answer the question
In order to leave comments, you need to log in
I think you should just start from the id of the comment that is loaded. Let's say comments with id 20,21,22 are loaded, 23 appeared, then 24, but there is nothing until the 20th, if the user clicks to load more, you just need to return comments up to the 20th with a certain limit.
The appearance of new ones does not affect the fact that the oldest is the 20th.
IMHO, you multiply entities, just load all the comments again, it will be faster and easier than manipulating a bunch of data on the front and then selecting pieces on the back.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question