From e4e0cf21a31b74d5ee1e6d45b343ea60ed44f372 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 8 Dec 2017 01:35:26 +0100 Subject: hootbox stuff --- public/assets/js/lib/views/index/hootbox.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (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..f93a689 100644 --- a/public/assets/js/lib/views/index/hootbox.js +++ b/public/assets/js/lib/views/index/hootbox.js @@ -5,6 +5,17 @@ var HootBox = FormView.extend({ events: { }, + validate: function(){ + var errors = [] + var comment = $("[name=comment]").val() + if (! comment || ! comment.length) { + errors.push("Please enter a comment.") + } + return errors.length ? errors : null + }, + + action: "/api/thread/1/comment", + initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() @@ -31,7 +42,8 @@ var HootBox = FormView.extend({ this.$hoots.append($el) }, - success: function(){ + success: function(comment){ this.prependComment(comment) + this.$("[name=comment]").val("") } }) \ No newline at end of file -- cgit v1.2.3-70-g09d2