diff options
Diffstat (limited to 'public/assets/js/lib/views/index/hootbox.js')
| -rw-r--r-- | public/assets/js/lib/views/index/hootbox.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js index f93a689..cdd3eb0 100644 --- a/public/assets/js/lib/views/index/hootbox.js +++ b/public/assets/js/lib/views/index/hootbox.js @@ -5,21 +5,13 @@ 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() this.$hoots = this.$("#hoots") + this.$comment = this.$("[name=comment]") }, load: function(comments){ @@ -41,7 +33,16 @@ var HootBox = FormView.extend({ var $el = $( this.parse(comment) ) this.$hoots.append($el) }, - + + validate: function(){ + var errors = [] + var comment = $("[name=comment]").val() + if (! comment || ! comment.length) { + errors.push("Please enter a comment.") + } + return errors.length ? errors : null + }, + success: function(comment){ this.prependComment(comment) this.$("[name=comment]").val("") |
