|
@@ -87,6 +87,15 @@ let CommentBox = React.createClass({
|
|
|
return { data: [] };
|
|
|
},
|
|
|
handleCommentSubmit: function (comment) {
|
|
|
+ let comments = this.state.data;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ comment.id = Date.now();
|
|
|
+ let newComments = comments.concat([comment]);
|
|
|
+
|
|
|
+ this.setState({ data: newComments });
|
|
|
+
|
|
|
$.ajax({
|
|
|
url: this.props.url,
|
|
|
dataType: "json",
|
|
@@ -96,6 +105,8 @@ let CommentBox = React.createClass({
|
|
|
this.setState({ data: data });
|
|
|
}.bind(this),
|
|
|
error: function (xhr, status, err) {
|
|
|
+
|
|
|
+ this.setState({data: comments });
|
|
|
console.error(this.props.url, status, err.toString());
|
|
|
}
|
|
|
});
|