Skip to content

Reply only works on page refresh #140

Open
@lbreguet

Description

@lbreguet

There's an issue I'm having with the Reply button. After posting a comment on the website, the comment gets saved to the server and appears on the page. When I click on the Reply button, however, nothing happens. Once I reload the page does the button actually do something.

Here's the code for posting a comment:

postComment: function(commentJSON, success, error) {
            commentJSON['__metadata'] = {  
                'type': 'SP.Data.CommentsListItem' // it defines the ListEnitityTypeName  
            }
            commentJSON.PageId = currentpage;
            commentJSON.FullName = currentuserName;
            commentJSON.CreatedByCurrentUser = false;
            delete commentJSON['pings']
            commentJSON.CommentId = commentJSON.Id;
            delete commentJSON['Id'];

            $.ajax({
                type: 'post',
                url: siteUrl + "/_api/web/lists/GetByTitle('Comments')/items",
                headers: {
                    "Accept": "application/json;odata=verbose",
                    "content-type": "application/json;odata=verbose; charset=UTF-8",
                    "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
                },
                data: JSON.stringify(commentJSON),
                success: function() {
                    success(commentJSON);
                    commentsArray.push(commentJSON);
                    $('.total-comments').text('Total comments: ' + commentsArray.length);
                    $('.total-comments-header').text(commentsArray.length);
                    console.log("new comment object: ");
                    console.log(commentJSON);
                },
                error: function (error) {
                    console.log(JSON.stringify(error));
                    console.log("Broke posting comment");
                    debugger;
                }
            });
        }

Keep in mind that I'm using Jquery Comments in a SharePoint page.

Any help would be much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions