I
I
Igor K2018-08-14 16:53:00
JavaScript
Igor K, 2018-08-14 16:53:00

Comment form when reloading a page?

Good afternoon!
I am currently developing the client side of the server, which allows you to upload images, draw on them and leave comments (as part of training in the specialty).
There are callable comment forms in the work ( After loading any picture, select the "Comments" menu in the burger and simply click on any point of this picture with the mouse - a comment icon appears, when you click again - a comment form opens ) - I enter several comments and everything is displayed in the form as it should, but after reloading the page, only the last comment remains in the form, and all comments should remain . In the JSON that comes from the server after the page reload, all comments are present, but only the last one is displayed.
Please do not kick too much - experience in development is small.
https://stormfluger.github.io/index.html

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Patient322, 2018-08-15
@Stormfluger

For each comment, a new form is created in the house, each at one point.
You are looking for '.comments__form' in wrappApp and you are adding a new form to wrapCommentsCanvas. In turn, wrapCommentsCanvas is added to wrappApp only after the image is loaded.
The easiest way is to fix in the setReview function to move the call to the updateCommentForm(dataGetParse.comments); in the callback for loading the image, it will look like this:

currentImage.addEventListener('load', () => {
    hideElement(loader);
    createWrapforCanvasComment();
    createCanvas();
    currentImage.dataset.load = 'load';
    updateCommentForm(dataGetParse.comments);
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question