diff options
Diffstat (limited to 'public/assets/js/lib/views/details')
| -rw-r--r-- | public/assets/js/lib/views/details/commentform.js | 22 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/details.js | 11 |
2 files changed, 26 insertions, 7 deletions
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); + } }, }); diff --git a/public/assets/js/lib/views/details/details.js b/public/assets/js/lib/views/details/details.js index 465655b..c1e7bf6 100644 --- a/public/assets/js/lib/views/details/details.js +++ b/public/assets/js/lib/views/details/details.js @@ -8,7 +8,10 @@ var DetailsView = View.extend({ this.comments = new CommentsView({ parent: this }); this.files = new FilesView({ parent: this }); this.gallery = new GalleryView({ parent: this }); - this.form = new CommentForm({ parent: this }); + this.form = new CommentForm({ + parent: this, + onSubmit: this.onSubmit.bind(this), + }); this.threadbox = new ThreadBox({ parent: this }); this.settings = new ThreadSettingsForm({ parent: this }); $(".settings_link").click(this.openSettings.bind(this)); @@ -63,4 +66,10 @@ var DetailsView = View.extend({ e && e.preventDefault(); this.settings.show(); }, + + onSubmit: function (data) { + data.comment && this.comments.load([data.comment]); + data.files && this.files.add(data.files); + data.files && this.gallery.add(data.files); + }, }); |
