From ed083ad3191a5d7d61abb21fa7dafec5121ecaab Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 25 Sep 2015 18:05:37 -0400 Subject: post comment --- public/assets/js/lib/views/index/hootbox.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'public/assets/js/lib/views/index/hootbox.js') diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js index 9d1cc3d..4a23d32 100644 --- a/public/assets/js/lib/views/index/hootbox.js +++ b/public/assets/js/lib/views/index/hootbox.js @@ -5,10 +5,13 @@ var HootBox = FormView.extend({ events: { }, + action: "/api/thread/1/comment", + initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() this.$hoots = this.$("#hoots") + this.$comment = this.$("[name=comment]") }, load: function(comments){ @@ -31,7 +34,23 @@ var HootBox = FormView.extend({ this.$hoots.append($el) }, - success: function(){ - this.prependComment(comment) + validate: function(){ + var errors = [] + if (! this.$comment.val()) { + errors.push("no comment") + return errors + } + return null + }, + + beforeSend: function(){ + this.$comment.val("") + }, + + showErrors: function(){ + }, + + success: function(data){ + this.prependComment(data.comment) } }) \ No newline at end of file -- cgit v1.2.3-70-g09d2