Не добавлять комментарий, если с сервера пришло {"error":"SomeError"}

This commit is contained in:
isqua 2015-02-07 19:03:24 +03:00
parent ad5ace57cb
commit ec6eb34e22

View file

@ -139,21 +139,25 @@ AjaxCommentProcessor.prototype.onSuccess = function(data, textStatus) {
var $textarea = this._$textarea; var $textarea = this._$textarea;
if (textStatus === 'success') { if (textStatus === 'success') {
this.hideForm(); if (data.error) {
this.onError(null, null, data.error);
// Creating the comment HTML } else {
create_comment_elements({ // Creating the comment HTML
id: data.comment_id, create_comment_elements({
toId: this._commentId || null, id: data.comment_id,
postId: this._postId, toId: this._commentId || null,
author: $('#name h1').text(), postId: this._postId,
text: this._text, author: $('#name h1').text(),
fadeOut: true text: this._text,
}, this.insertComment.bind(this)); fadeOut: true
}, this.insertComment.bind(this));
// Cleaning textarea this.hideForm();
$textarea.val('');
this.setProgress(false); // Cleaning textarea
$textarea.val('');
this.setProgress(false);
}
} }
}; };