From b39de8cc12c83029168f311a7d3e4ddd96d52635 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Fri, 28 Oct 2022 13:47:06 +0200 Subject: toggle form --- public/assets/js/lib/views/details/commentform.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'public/assets/js/lib/views/details/commentform.js') diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js index 6dddd26..708657d 100644 --- a/public/assets/js/lib/views/details/commentform.js +++ b/public/assets/js/lib/views/details/commentform.js @@ -13,6 +13,15 @@ var CommentForm = FormView.extend({ this.__super__.initialize.call(this, opt); this.template = this.$(".template").html(); this.$comment = this.$("[name=comment]"); + console.log("initialize"); + }, + + show: function () { + this.$el.show(); + }, + + hide: function () { + this.$el.hide(); }, load: function (thread) { @@ -40,8 +49,9 @@ var CommentForm = FormView.extend({ validate: function () { var errors = []; - var comment = $("[name=comment]").val(); + var comment = this.$("[name=comment]").val(); var files = this.$("[name=files]").val(); + console.log(comment, files); if ((!comment || !comment.length) && !files) { errors.push("Please enter a comment or add some files."); } @@ -52,11 +62,11 @@ var CommentForm = FormView.extend({ $("[name=comment").val(""); $("[name=files").val(""); // window.location.reload() - console.log(this); - console.log(this.parent); + // console.log(this); + // console.log(this.parent); console.log(data); - data.comment && this.parent.comments.load([data.comment]); - data.files && this.parent.files.add(data.files); - data.files && this.parent.gallery.add(data.files); + if (this.opt.onSubmit) { + this.opt.onSubmit(data); + } }, }); -- cgit v1.2.3-70-g09d2