var CommentForm = FormView.extend({ el: "#comment_form", events: { }, action: "/api/thread/1/comment", initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() this.$comment = this.$("[name=comment]") }, load: function(thread){ this.action = "/api/thread/" + thread.id + "/comment" }, 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("") } })