import {Component} from './component';
-import {getLoading, htmlToDom} from '../services/dom';
+import {getLoading, htmlToDom} from '../services/dom.ts';
import {buildForInput} from '../wysiwyg-tinymce/config';
export class PageComments extends Component {
setupListeners() {
this.elem.addEventListener('page-comment-delete', () => {
- this.updateCount();
+ setTimeout(() => this.updateCount(), 1);
this.hideForm();
});
window.$http.post(`/comment/${this.pageId}`, reqData).then(resp => {
const newElem = htmlToDom(resp.data);
- this.formContainer.after(newElem);
+
+ if (reqData.parent_id) {
+ this.formContainer.after(newElem);
+ } else {
+ this.container.append(newElem);
+ }
+
window.$events.success(this.createdText);
this.hideForm();
this.updateCount();
updateCount() {
const count = this.getCommentCount();
- this.commentsTitle.textContent = window.trans_plural(this.countText, count, {count});
+ this.commentsTitle.textContent = window.$trans.choice(this.countText, count, {count});
}
resetForm() {